1
0
mirror of https://github.com/golang/go synced 2024-11-21 15:54:43 -07:00

io: use SetFinalizer more elegantly in Pipe

(this works now that issue 751 is resolved)

R=rsc
CC=golang-dev
https://golang.org/cl/2834041
This commit is contained in:
Christopher Wedgwood 2010-11-05 15:05:39 -04:00 committed by Russ Cox
parent c9d39dca8d
commit 6101788972

View File

@ -292,20 +292,14 @@ func Pipe() (*PipeReader, *PipeWriter) {
r.c2 = p.r2
r.cclose = p.rclose
r.done = p.done
// TODO(rsc): Should be able to write
// runtime.SetFinalizer(r, (*PipeReader).finalizer)
// but 6g doesn't see the finalizer method.
runtime.SetFinalizer(&r.pipeHalf, (*pipeHalf).finalizer)
runtime.SetFinalizer(r, (*PipeReader).finalizer)
w := new(PipeWriter)
w.c1 = p.w1
w.c2 = p.w2
w.cclose = p.wclose
w.done = p.done
// TODO(rsc): Should be able to write
// runtime.SetFinalizer(w, (*PipeWriter).finalizer)
// but 6g doesn't see the finalizer method.
runtime.SetFinalizer(&w.pipeHalf, (*pipeHalf).finalizer)
runtime.SetFinalizer(w, (*PipeWriter).finalizer)
return r, w
}