diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 163330de2..f92a81af7 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -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", diff --git a/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go b/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go index 762cecb20..17cb37799 100644 --- a/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go +++ b/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go @@ -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. diff --git a/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go b/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go index 26bb5b42b..8516e03d0 100644 --- a/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go +++ b/Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go @@ -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() diff --git a/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go b/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go index 47a73fedd..de246a8fa 100644 --- a/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go +++ b/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go @@ -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 {