Commit e2601ebc authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge pull request #1392 from ipfs/update-goprocess-dep

update goprocess godep
parents 41b7f6d3 c274a3f6
......@@ -38,6 +38,10 @@
"ImportPath": "github.com/cheggaaa/pb",
"Rev": "d7729fd7ec1372c15b83db39834bf842bf2d69fb"
},
{
"ImportPath": "github.com/chriscool/go-sleep",
"Rev": "743ab5f1bb487edf1772bc29ca0bdf572b40785e"
},
{
"ImportPath": "github.com/codahale/hdrhistogram",
"Rev": "5fd85ec0b4e2dd5d4158d257d943f2e586d86b62"
......@@ -184,7 +188,7 @@
},
{
"ImportPath": "github.com/jbenet/goprocess",
"Rev": "ea63e9540cd19cb39e0e4c4442b9c27664287bb8"
"Rev": "67fe91f1081e806f1bb51051c972ac782ea46d85"
},
{
"ImportPath": "github.com/kardianos/osext",
......
......@@ -115,6 +115,9 @@ type Process interface {
// It is useful to construct simple asynchronous workers, children of p.
Go(f ProcessFunc) Process
// SetTeardown sets the process's teardown to tf.
SetTeardown(tf TeardownFunc)
// Close ends the process. Close blocks until the process has completely
// shut down, and any teardown has run _exactly once_. The returned error
// is available indefinitely: calling Close twice returns the same error.
......
......@@ -123,17 +123,13 @@ func TestTeardownCalledOnce(t *testing.T) {
}
}
setTeardown := func(t tree, tf TeardownFunc) {
t.Process.(*process).teardown = tf
}
setTeardown(a, onlyOnce())
setTeardown(a.c[0], onlyOnce())
setTeardown(a.c[0].c[0], onlyOnce())
setTeardown(a.c[0].c[1], onlyOnce())
setTeardown(a.c[1], onlyOnce())
setTeardown(a.c[1].c[0], onlyOnce())
setTeardown(a.c[1].c[1], onlyOnce())
a.SetTeardown(onlyOnce())
a.c[0].SetTeardown(onlyOnce())
a.c[0].c[0].SetTeardown(onlyOnce())
a.c[0].c[1].SetTeardown(onlyOnce())
a.c[1].SetTeardown(onlyOnce())
a.c[1].c[0].SetTeardown(onlyOnce())
a.c[1].c[1].SetTeardown(onlyOnce())
a.c[0].c[0].Close()
a.c[0].c[0].Close()
......
......@@ -114,6 +114,16 @@ func (p *process) Go(f ProcessFunc) Process {
return child
}
// SetTeardown to assign a teardown function
func (p *process) SetTeardown(tf TeardownFunc) {
if tf == nil {
tf = nilTeardownFunc
}
p.Lock()
p.teardown = tf
p.Unlock()
}
// Close is the external close function.
// it's a wrapper around internalClose that waits on Closed()
func (p *process) Close() error {
......
......@@ -6,3 +6,4 @@ import _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-hum
// similar to the above, only used in the tests makefile
import _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/iptb"
import _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/chriscool/go-sleep"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment