update goprocess dep
Learned proc.SetTeardown() License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
Juan Batiz-Benet committed
Jun 18, 2015 at 02:09 UTC
c274a3f6e1260166382b4e98338c8d85da0902f0
4 files changed
+25
-12
Godeps/Godeps.json
+5
-1
@@ -38,6 +38,10 @@
38
"ImportPath": "github.com/cheggaaa/pb",
39
"Rev": "d7729fd7ec1372c15b83db39834bf842bf2d69fb"
40
},
41
+ {
42
+ "ImportPath": "github.com/chriscool/go-sleep",
43
+ "Rev": "743ab5f1bb487edf1772bc29ca0bdf572b40785e"
44
+ },
45
{
46
"ImportPath": "github.com/codahale/hdrhistogram",
47
"Rev": "5fd85ec0b4e2dd5d4158d257d943f2e586d86b62"
@@ -184,7 +188,7 @@
188
},
189
{
190
"ImportPath": "github.com/jbenet/goprocess",
187
- "Rev": "ea63e9540cd19cb39e0e4c4442b9c27664287bb8"
191
+ "Rev": "67fe91f1081e806f1bb51051c972ac782ea46d85"
192
},
193
{
194
"ImportPath": "github.com/kardianos/osext",
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go
+3
@@ -115,6 +115,9 @@ type Process interface {
115
// It is useful to construct simple asynchronous workers, children of p.
116
Go(f ProcessFunc) Process
117
118
+ // SetTeardown sets the process's teardown to tf.
119
+ SetTeardown(tf TeardownFunc)
120
+
121
// Close ends the process. Close blocks until the process has completely
122
// shut down, and any teardown has run _exactly once_. The returned error
123
// is available indefinitely: calling Close twice returns the same error.
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
+7
-11
@@ -123,17 +123,13 @@ func TestTeardownCalledOnce(t *testing.T) {
123
}
124
}
125
126
- setTeardown := func(t tree, tf TeardownFunc) {
127
- t.Process.(*process).teardown = tf
128
- }
129
-
130
- setTeardown(a, onlyOnce())
131
- setTeardown(a.c[0], onlyOnce())
132
- setTeardown(a.c[0].c[0], onlyOnce())
133
- setTeardown(a.c[0].c[1], onlyOnce())
134
- setTeardown(a.c[1], onlyOnce())
135
- setTeardown(a.c[1].c[0], onlyOnce())
136
- setTeardown(a.c[1].c[1], onlyOnce())
126
+ a.SetTeardown(onlyOnce())
127
+ a.c[0].SetTeardown(onlyOnce())
128
+ a.c[0].c[0].SetTeardown(onlyOnce())
129
+ a.c[0].c[1].SetTeardown(onlyOnce())
130
+ a.c[1].SetTeardown(onlyOnce())
131
+ a.c[1].c[0].SetTeardown(onlyOnce())
132
+ a.c[1].c[1].SetTeardown(onlyOnce())
133
134
a.c[0].c[0].Close()
135
a.c[0].c[0].Close()
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
+10
@@ -114,6 +114,16 @@ func (p *process) Go(f ProcessFunc) Process {
114
return child
115
}
116
117
+// SetTeardown to assign a teardown function
118
+func (p *process) SetTeardown(tf TeardownFunc) {
119
+ if tf == nil {
120
+ tf = nilTeardownFunc
121
+ }
122
+ p.Lock()
123
+ p.teardown = tf
124
+ p.Unlock()
125
+}
126
+
127
// Close is the external close function.
128
// it's a wrapper around internalClose that waits on Closed()
129
func (p *process) Close() error {