@cryptotaxi247 / kubo / commits / 3faedb520

remove goprocess from godeps, use gx vendored one

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Feb 8, 2016 at 16:45 UTC 3faedb52086cf16b88cc83d3c0e9eedae2b83758
36 files changed +35 -2462
Godeps/_workspace/src/github.com/ipfs/go-datastore/leveldb/datastore.go
+2 -1
@@ -3,10 +3,11 @@ package leveldb
3 import (
4 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
6 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb"
7 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt"
8 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util"
9 +
10 + "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
11 )
12
13 type datastore struct {
Godeps/_workspace/src/github.com/ipfs/go-datastore/query/query.go
+1 -1
@@ -1,7 +1,7 @@
1 package query
2
3 import (
4 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
4 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
5 )
6
7 /*
Godeps/_workspace/src/github.com/jbenet/goprocess/.travis.yml deleted
-10
@@ -1,10 +0,0 @@
1 -sudo: false
2 -
3 -language: go
4 -
5 -go:
6 - - 1.3
7 - - 1.4
8 -
9 -script:
10 - - go test -race -cpu=5 -v ./...
Godeps/_workspace/src/github.com/jbenet/goprocess/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Juan Batiz-Benet
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/jbenet/goprocess/README.md deleted
-132
@@ -1,132 +0,0 @@
1 -# goprocess - lifecycles in go
2 -
3 -[![travisbadge](https://travis-ci.org/jbenet/goprocess.svg)](https://travis-ci.org/jbenet/goprocess)
4 -
5 -(Based on https://github.com/jbenet/go-ctxgroup)
6 -
7 -- Godoc: https://godoc.org/github.com/jbenet/goprocess
8 -
9 -`goprocess` introduces a way to manage process lifecycles in go. It is
10 -much like [go.net/context](https://godoc.org/code.google.com/p/go.net/context)
11 -(it actually uses a Context), but it is more like a Context-WaitGroup hybrid.
12 -`goprocess` is about being able to start and stop units of work, which may
13 -receive `Close` signals from many clients. Think of it like a UNIX process
14 -tree, but inside go.
15 -
16 -`goprocess` seeks to minimally affect your objects, so you can use it
17 -with both embedding or composition. At the heart of `goprocess` is the
18 -`Process` interface:
19 -
20 -```Go
21 -// Process is the basic unit of work in goprocess. It defines a computation
22 -// with a lifecycle:
23 -// - running (before calling Close),
24 -// - closing (after calling Close at least once),
25 -// - closed (after Close returns, and all teardown has _completed_).
26 -//
27 -// More specifically, it fits this:
28 -//
29 -// p := WithTeardown(tf) // new process is created, it is now running.
30 -// p.AddChild(q) // can register children **before** Closing.
31 -// go p.Close() // blocks until done running teardown func.
32 -// <-p.Closing() // would now return true.
33 -// <-p.childrenDone() // wait on all children to be done
34 -// p.teardown() // runs the user's teardown function tf.
35 -// p.Close() // now returns, with error teardown returned.
36 -// <-p.Closed() // would now return true.
37 -//
38 -// Processes can be arranged in a process "tree", where children are
39 -// automatically Closed if their parents are closed. (Note, it is actually
40 -// a Process DAG, children may have multiple parents). A process may also
41 -// optionally wait for another to fully Close before beginning to Close.
42 -// This makes it easy to ensure order of operations and proper sequential
43 -// teardown of resurces. For example:
44 -//
45 -// p1 := goprocess.WithTeardown(func() error {
46 -// fmt.Println("closing 1")
47 -// })
48 -// p2 := goprocess.WithTeardown(func() error {
49 -// fmt.Println("closing 2")
50 -// })
51 -// p3 := goprocess.WithTeardown(func() error {
52 -// fmt.Println("closing 3")
53 -// })
54 -//
55 -// p1.AddChild(p2)
56 -// p2.AddChild(p3)
57 -//
58 -//
59 -// go p1.Close()
60 -// go p2.Close()
61 -// go p3.Close()
62 -//
63 -// // Output:
64 -// // closing 3
65 -// // closing 2
66 -// // closing 1
67 -//
68 -// Process is modelled after the UNIX processes group idea, and heavily
69 -// informed by sync.WaitGroup and go.net/context.Context.
70 -//
71 -// In the function documentation of this interface, `p` always refers to
72 -// the self Process.
73 -type Process interface {
74 -
75 - // WaitFor makes p wait for q before exiting. Thus, p will _always_ close
76 - // _after_ q. Note well: a waiting cycle is deadlock.
77 - //
78 - // If q is already Closed, WaitFor calls p.Close()
79 - // If p is already Closing or Closed, WaitFor panics. This is the same thing
80 - // as calling Add(1) _after_ calling Done() on a wait group. Calling WaitFor
81 - // on an already-closed process is a programming error likely due to bad
82 - // synchronization
83 - WaitFor(q Process)
84 -
85 - // AddChildNoWait registers child as a "child" of Process. As in UNIX,
86 - // when parent is Closed, child is Closed -- child may Close beforehand.
87 - // This is the equivalent of calling:
88 - //
89 - // go func(parent, child Process) {
90 - // <-parent.Closing()
91 - // child.Close()
92 - // }(p, q)
93 - //
94 - // Note: the naming of functions is `AddChildNoWait` and `AddChild` (instead
95 - // of `AddChild` and `AddChildWaitFor`) because:
96 - // - it is the more common operation,
97 - // - explicitness is helpful in the less common case (no waiting), and
98 - // - usual "child" semantics imply parent Processes should wait for children.
99 - AddChildNoWait(q Process)
100 -
101 - // AddChild is the equivalent of calling:
102 - // parent.AddChildNoWait(q)
103 - // parent.WaitFor(q)
104 - AddChild(q Process)
105 -
106 - // Go creates a new process, adds it as a child, and spawns the ProcessFunc f
107 - // in its own goroutine. It is equivalent to:
108 - //
109 - // GoChild(p, f)
110 - //
111 - // It is useful to construct simple asynchronous workers, children of p.
112 - Go(f ProcessFunc) Process
113 -
114 - // Close ends the process. Close blocks until the process has completely
115 - // shut down, and any teardown has run _exactly once_. The returned error
116 - // is available indefinitely: calling Close twice returns the same error.
117 - // If the process has already been closed, Close returns immediately.
118 - Close() error
119 -
120 - // Closing is a signal to wait upon. The returned channel is closed
121 - // _after_ Close has been called at least once, but teardown may or may
122 - // not be done yet. The primary use case of Closing is for children who
123 - // need to know when a parent is shutting down, and therefore also shut
124 - // down.
125 - Closing() <-chan struct{}
126 -
127 - // Closed is a signal to wait upon. The returned channel is closed
128 - // _after_ Close has completed; teardown has finished. The primary use case
129 - // of Closed is waiting for a Process to Close without _causing_ the Close.
130 - Closed() <-chan struct{}
131 -}
132 -```
Godeps/_workspace/src/github.com/jbenet/goprocess/context/context.go deleted
-110
@@ -1,110 +0,0 @@
1 -package goprocessctx
2 -
3 -import (
4 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
5 - context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
6 -)
7 -
8 -// WithContext constructs and returns a Process that respects
9 -// given context. It is the equivalent of:
10 -//
11 -// func ProcessWithContext(ctx context.Context) goprocess.Process {
12 -// p := goprocess.WithParent(goprocess.Background())
13 -// CloseAfterContext(p, ctx)
14 -// return p
15 -// }
16 -//
17 -func WithContext(ctx context.Context) goprocess.Process {
18 - p := goprocess.WithParent(goprocess.Background())
19 - CloseAfterContext(p, ctx)
20 - return p
21 -}
22 -
23 -// WithContextAndTeardown is a helper function to set teardown at initiation
24 -// of WithContext
25 -func WithContextAndTeardown(ctx context.Context, tf goprocess.TeardownFunc) goprocess.Process {
26 - p := goprocess.WithTeardown(tf)
27 - CloseAfterContext(p, ctx)
28 - return p
29 -}
30 -
31 -// WaitForContext makes p WaitFor ctx. When Closing, p waits for
32 -// ctx.Done(), before being Closed(). It is simply:
33 -//
34 -// p.WaitFor(goprocess.WithContext(ctx))
35 -//
36 -func WaitForContext(ctx context.Context, p goprocess.Process) {
37 - p.WaitFor(WithContext(ctx))
38 -}
39 -
40 -// CloseAfterContext schedules the process to close after the given
41 -// context is done. It is the equivalent of:
42 -//
43 -// func CloseAfterContext(p goprocess.Process, ctx context.Context) {
44 -// go func() {
45 -// <-ctx.Done()
46 -// p.Close()
47 -// }()
48 -// }
49 -//
50 -func CloseAfterContext(p goprocess.Process, ctx context.Context) {
51 - if p == nil {
52 - panic("nil Process")
53 - }
54 - if ctx == nil {
55 - panic("nil Context")
56 - }
57 -
58 - // context.Background(). if ctx.Done() is nil, it will never be done.
59 - // we check for this to avoid wasting a goroutine forever.
60 - if ctx.Done() == nil {
61 - return
62 - }
63 -
64 - go func() {
65 - <-ctx.Done()
66 - p.Close()
67 - }()
68 -}
69 -
70 -// WithProcessClosing returns a context.Context derived from ctx that
71 -// is cancelled as p is Closing (after: <-p.Closing()). It is simply:
72 -//
73 -// func WithProcessClosing(ctx context.Context, p goprocess.Process) context.Context {
74 -// ctx, cancel := context.WithCancel(ctx)
75 -// go func() {
76 -// <-p.Closing()
77 -// cancel()
78 -// }()
79 -// return ctx
80 -// }
81 -//
82 -func WithProcessClosing(ctx context.Context, p goprocess.Process) context.Context {
83 - ctx, cancel := context.WithCancel(ctx)
84 - go func() {
85 - <-p.Closing()
86 - cancel()
87 - }()
88 - return ctx
89 -}
90 -
91 -// WithProcessClosed returns a context.Context that is cancelled
92 -// after Process p is Closed. It is the equivalent of:
93 -//
94 -// func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context {
95 -// ctx, cancel := context.WithCancel(ctx)
96 -// go func() {
97 -// <-p.Closed()
98 -// cancel()
99 -// }()
100 -// return ctx
101 -// }
102 -//
103 -func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context {
104 - ctx, cancel := context.WithCancel(ctx)
105 - go func() {
106 - <-p.Closed()
107 - cancel()
108 - }()
109 - return ctx
110 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/context/derive.go deleted
-59
@@ -1,59 +0,0 @@
1 -package goprocessctx
2 -
3 -import (
4 - "errors"
5 - "time"
6 -
7 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9 -)
10 -
11 -const (
12 - closing = iota
13 - closed
14 -)
15 -
16 -type procContext struct {
17 - done <-chan struct{}
18 - which int
19 -}
20 -
21 -// OnClosingContext derives a context from a given goprocess that will
22 -// be 'Done' when the process is closing
23 -func OnClosingContext(p goprocess.Process) context.Context {
24 - return &procContext{
25 - done: p.Closing(),
26 - which: closing,
27 - }
28 -}
29 -
30 -// OnClosedContext derives a context from a given goprocess that will
31 -// be 'Done' when the process is closed
32 -func OnClosedContext(p goprocess.Process) context.Context {
33 - return &procContext{
34 - done: p.Closed(),
35 - which: closed,
36 - }
37 -}
38 -
39 -func (c *procContext) Done() <-chan struct{} {
40 - return c.done
41 -}
42 -
43 -func (c *procContext) Deadline() (time.Time, bool) {
44 - return time.Time{}, false
45 -}
46 -
47 -func (c *procContext) Err() error {
48 - if c.which == closing {
49 - return errors.New("process closing")
50 - } else if c.which == closed {
51 - return errors.New("process closed")
52 - } else {
53 - panic("unrecognized process context type")
54 - }
55 -}
56 -
57 -func (c *procContext) Value(key interface{}) interface{} {
58 - return nil
59 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/example_test.go deleted
-37
@@ -1,37 +0,0 @@
1 -package goprocess_test
2 -
3 -import (
4 - "fmt"
5 - "time"
6 -
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 -)
9 -
10 -func ExampleGo() {
11 - p := goprocess.Go(func(p goprocess.Process) {
12 - ticker := time.Tick(200 * time.Millisecond)
13 - for {
14 - select {
15 - case <-ticker:
16 - fmt.Println("tick")
17 - case <-p.Closing():
18 - fmt.Println("closing")
19 - return
20 - }
21 - }
22 - })
23 -
24 - <-time.After(1100 * time.Millisecond)
25 - p.Close()
26 - fmt.Println("closed")
27 - <-time.After(100 * time.Millisecond)
28 -
29 - // Output:
30 - // tick
31 - // tick
32 - // tick
33 - // tick
34 - // tick
35 - // closing
36 - // closed
37 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go deleted
-283
@@ -1,283 +0,0 @@
1 -// Package goprocess introduces a Process abstraction that allows simple
2 -// organization, and orchestration of work. It is much like a WaitGroup,
3 -// and much like a context.Context, but also ensures safe **exactly-once**,
4 -// and well-ordered teardown semantics.
5 -package goprocess
6 -
7 -import (
8 - "os"
9 - "os/signal"
10 -)
11 -
12 -// Process is the basic unit of work in goprocess. It defines a computation
13 -// with a lifecycle:
14 -// - running (before calling Close),
15 -// - closing (after calling Close at least once),
16 -// - closed (after Close returns, and all teardown has _completed_).
17 -//
18 -// More specifically, it fits this:
19 -//
20 -// p := WithTeardown(tf) // new process is created, it is now running.
21 -// p.AddChild(q) // can register children **before** Closed().
22 -// go p.Close() // blocks until done running teardown func.
23 -// <-p.Closing() // would now return true.
24 -// <-p.childrenDone() // wait on all children to be done
25 -// p.teardown() // runs the user's teardown function tf.
26 -// p.Close() // now returns, with error teardown returned.
27 -// <-p.Closed() // would now return true.
28 -//
29 -// Processes can be arranged in a process "tree", where children are
30 -// automatically Closed if their parents are closed. (Note, it is actually
31 -// a Process DAG, children may have multiple parents). A process may also
32 -// optionally wait for another to fully Close before beginning to Close.
33 -// This makes it easy to ensure order of operations and proper sequential
34 -// teardown of resurces. For example:
35 -//
36 -// p1 := goprocess.WithTeardown(func() error {
37 -// fmt.Println("closing 1")
38 -// })
39 -// p2 := goprocess.WithTeardown(func() error {
40 -// fmt.Println("closing 2")
41 -// })
42 -// p3 := goprocess.WithTeardown(func() error {
43 -// fmt.Println("closing 3")
44 -// })
45 -//
46 -// p1.AddChild(p2)
47 -// p2.AddChild(p3)
48 -//
49 -//
50 -// go p1.Close()
51 -// go p2.Close()
52 -// go p3.Close()
53 -//
54 -// // Output:
55 -// // closing 3
56 -// // closing 2
57 -// // closing 1
58 -//
59 -// Process is modelled after the UNIX processes group idea, and heavily
60 -// informed by sync.WaitGroup and go.net/context.Context.
61 -//
62 -// In the function documentation of this interface, `p` always refers to
63 -// the self Process.
64 -type Process interface {
65 -
66 - // WaitFor makes p wait for q before exiting. Thus, p will _always_ close
67 - // _after_ q. Note well: a waiting cycle is deadlock.
68 - //
69 - // If q is already Closed, WaitFor calls p.Close()
70 - // If p is already Closing or Closed, WaitFor panics. This is the same thing
71 - // as calling Add(1) _after_ calling Done() on a wait group. Calling WaitFor
72 - // on an already-closed process is a programming error likely due to bad
73 - // synchronization
74 - WaitFor(q Process)
75 -
76 - // AddChildNoWait registers child as a "child" of Process. As in UNIX,
77 - // when parent is Closed, child is Closed -- child may Close beforehand.
78 - // This is the equivalent of calling:
79 - //
80 - // go func(parent, child Process) {
81 - // <-parent.Closing()
82 - // child.Close()
83 - // }(p, q)
84 - //
85 - // Note: the naming of functions is `AddChildNoWait` and `AddChild` (instead
86 - // of `AddChild` and `AddChildWaitFor`) because:
87 - // - it is the more common operation,
88 - // - explicitness is helpful in the less common case (no waiting), and
89 - // - usual "child" semantics imply parent Processes should wait for children.
90 - AddChildNoWait(q Process)
91 -
92 - // AddChild is the equivalent of calling:
93 - // parent.AddChildNoWait(q)
94 - // parent.WaitFor(q)
95 - AddChild(q Process)
96 -
97 - // Go is much like `go`, as it runs a function in a newly spawned goroutine.
98 - // The neat part of Process.Go is that the Process object you call it on will:
99 - // * construct a child Process, and call AddChild(child) on it
100 - // * spawn a goroutine, and call the given function
101 - // * Close the child when the function exits.
102 - // This way, you can rest assured each goroutine you spawn has its very own
103 - // Process context, and that it will be closed when the function exits.
104 - // It is the function's responsibility to respect the Closing of its Process,
105 - // namely it should exit (return) when <-Closing() is ready. It is basically:
106 - //
107 - // func (p Process) Go(f ProcessFunc) Process {
108 - // child := WithParent(p)
109 - // go func () {
110 - // f(child)
111 - // child.Close()
112 - // }()
113 - // }
114 - //
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.
124 - // If the process has already been closed, Close returns immediately.
125 - Close() error
126 -
127 - // CloseAfterChildren calls Close _after_ its children have Closed
128 - // normally (i.e. it _does not_ attempt to close them).
129 - CloseAfterChildren() error
130 -
131 - // Closing is a signal to wait upon. The returned channel is closed
132 - // _after_ Close has been called at least once, but teardown may or may
133 - // not be done yet. The primary use case of Closing is for children who
134 - // need to know when a parent is shutting down, and therefore also shut
135 - // down.
136 - Closing() <-chan struct{}
137 -
138 - // Closed is a signal to wait upon. The returned channel is closed
139 - // _after_ Close has completed; teardown has finished. The primary use case
140 - // of Closed is waiting for a Process to Close without _causing_ the Close.
141 - Closed() <-chan struct{}
142 -
143 - // Err waits until the process is closed, and then returns any error that
144 - // occurred during shutdown.
145 - Err() error
146 -}
147 -
148 -// TeardownFunc is a function used to cleanup state at the end of the
149 -// lifecycle of a Process.
150 -type TeardownFunc func() error
151 -
152 -// ProcessFunc is a function that takes a process. Its main use case is goprocess.Go,
153 -// which spawns a ProcessFunc in its own goroutine, and returns a corresponding
154 -// Process object.
155 -type ProcessFunc func(proc Process)
156 -
157 -var nilProcessFunc = func(Process) {}
158 -
159 -// Go is much like `go`: it runs a function in a newly spawned goroutine. The neat
160 -// part of Go is that it provides Process object to communicate between the
161 -// function and the outside world. Thus, callers can easily WaitFor, or Close the
162 -// function. It is the function's responsibility to respect the Closing of its Process,
163 -// namely it should exit (return) when <-Closing() is ready. It is simply:
164 -//
165 -// func Go(f ProcessFunc) Process {
166 -// p := WithParent(Background())
167 -// p.Go(f)
168 -// return p
169 -// }
170 -//
171 -// Note that a naive implementation of Go like the following would not work:
172 -//
173 -// func Go(f ProcessFunc) Process {
174 -// return Background().Go(f)
175 -// }
176 -//
177 -// This is because having the process you
178 -func Go(f ProcessFunc) Process {
179 - // return GoChild(Background(), f)
180 -
181 - // we use two processes, one for communication, and
182 - // one for ensuring we wait on the function (unclosable from the outside).
183 - p := newProcess(nil)
184 - waitFor := newProcess(nil)
185 - p.WaitFor(waitFor) // prevent p from closing
186 - go func() {
187 - f(p)
188 - waitFor.Close() // allow p to close.
189 - p.Close() // ensure p closes.
190 - }()
191 - return p
192 -}
193 -
194 -// GoChild is like Go, but it registers the returned Process as a child of parent,
195 -// **before** spawning the goroutine, which ensures proper synchronization with parent.
196 -// It is somewhat like
197 -//
198 -// func GoChild(parent Process, f ProcessFunc) Process {
199 -// p := WithParent(parent)
200 -// p.Go(f)
201 -// return p
202 -// }
203 -//
204 -// And it is similar to the classic WaitGroup use case:
205 -//
206 -// func WaitGroupGo(wg sync.WaitGroup, child func()) {
207 -// wg.Add(1)
208 -// go func() {
209 -// child()
210 -// wg.Done()
211 -// }()
212 -// }
213 -//
214 -func GoChild(parent Process, f ProcessFunc) Process {
215 - p := WithParent(parent)
216 - p.Go(f)
217 - return p
218 -}
219 -
220 -// Spawn is an alias of `Go`. In many contexts, Spawn is a
221 -// well-known Process launching word, which fits our use case.
222 -var Spawn = Go
223 -
224 -// SpawnChild is an alias of `GoChild`. In many contexts, Spawn is a
225 -// well-known Process launching word, which fits our use case.
226 -var SpawnChild = GoChild
227 -
228 -// WithTeardown constructs and returns a Process with a TeardownFunc.
229 -// TeardownFunc tf will be called **exactly-once** when Process is
230 -// Closing, after all Children have fully closed, and before p is Closed.
231 -// In fact, Process p will not be Closed until tf runs and exits.
232 -// See lifecycle in Process doc.
233 -func WithTeardown(tf TeardownFunc) Process {
234 - if tf == nil {
235 - panic("nil tf TeardownFunc")
236 - }
237 - return newProcess(tf)
238 -}
239 -
240 -// WithParent constructs and returns a Process with a given parent.
241 -func WithParent(parent Process) Process {
242 - if parent == nil {
243 - panic("nil parent Process")
244 - }
245 - q := newProcess(nil)
246 - parent.AddChild(q)
247 - return q
248 -}
249 -
250 -// WithSignals returns a Process that will Close() when any given signal fires.
251 -// This is useful to bind Process trees to syscall.SIGTERM, SIGKILL, etc.
252 -func WithSignals(sig ...os.Signal) Process {
253 - p := WithParent(Background())
254 - c := make(chan os.Signal)
255 - signal.Notify(c, sig...)
256 - go func() {
257 - <-c
258 - signal.Stop(c)
259 - p.Close()
260 - }()
261 - return p
262 -}
263 -
264 -// Background returns the "background" Process: a statically allocated
265 -// process that can _never_ close. It also never enters Closing() state.
266 -// Calling Background().Close() will hang indefinitely.
267 -func Background() Process {
268 - return background
269 -}
270 -
271 -// background is the background process
272 -var background = &unclosable{Process: newProcess(nil)}
273 -
274 -// unclosable is a process that _cannot_ be closed. calling Close simply hangs.
275 -type unclosable struct {
276 - Process
277 -}
278 -
279 -func (p *unclosable) Close() error {
280 - var hang chan struct{}
281 - <-hang // hang forever
282 - return nil
283 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go deleted
-638
@@ -1,638 +0,0 @@
1 -package goprocess
2 -
3 -import (
4 - "fmt"
5 - "runtime"
6 - "syscall"
7 - "testing"
8 - "time"
9 -)
10 -
11 -type tree struct {
12 - Process
13 - c []tree
14 -}
15 -
16 -func setupHierarchy(p Process) tree {
17 - t := func(n Process, ts ...tree) tree {
18 - return tree{n, ts}
19 - }
20 -
21 - a := WithParent(p)
22 - b1 := WithParent(a)
23 - b2 := WithParent(a)
24 - c1 := WithParent(b1)
25 - c2 := WithParent(b1)
26 - c3 := WithParent(b2)
27 - c4 := WithParent(b2)
28 -
29 - return t(a, t(b1, t(c1), t(c2)), t(b2, t(c3), t(c4)))
30 -}
31 -
32 -func TestClosingClosed(t *testing.T) {
33 -
34 - bWait := make(chan struct{})
35 - a := WithParent(Background())
36 - a.Go(func(proc Process) {
37 - <-bWait
38 - })
39 -
40 - Q := make(chan string, 3)
41 -
42 - go func() {
43 - <-a.Closing()
44 - Q <- "closing"
45 - bWait <- struct{}{}
46 - }()
47 -
48 - go func() {
49 - <-a.Closed()
50 - Q <- "closed"
51 - }()
52 -
53 - go func() {
54 - a.Close()
55 - Q <- "closed"
56 - }()
57 -
58 - if q := <-Q; q != "closing" {
59 - t.Error("order incorrect. closing not first")
60 - }
61 - if q := <-Q; q != "closed" {
62 - t.Error("order incorrect. closing not first")
63 - }
64 - if q := <-Q; q != "closed" {
65 - t.Error("order incorrect. closing not first")
66 - }
67 -}
68 -
69 -func TestChildFunc(t *testing.T) {
70 - a := WithParent(Background())
71 -
72 - wait1 := make(chan struct{})
73 - wait2 := make(chan struct{})
74 - wait3 := make(chan struct{})
75 - wait4 := make(chan struct{})
76 -
77 - a.Go(func(process Process) {
78 - wait1 <- struct{}{}
79 - <-wait2
80 - wait3 <- struct{}{}
81 - })
82 -
83 - go func() {
84 - a.Close()
85 - wait4 <- struct{}{}
86 - }()
87 -
88 - <-wait1
89 - select {
90 - case <-wait3:
91 - t.Error("should not be closed yet")
92 - case <-wait4:
93 - t.Error("should not be closed yet")
94 - case <-a.Closed():
95 - t.Error("should not be closed yet")
96 - default:
97 - }
98 -
99 - wait2 <- struct{}{}
100 -
101 - select {
102 - case <-wait3:
103 - case <-time.After(time.Second):
104 - t.Error("should be closed now")
105 - }
106 -
107 - select {
108 - case <-wait4:
109 - case <-time.After(time.Second):
110 - t.Error("should be closed now")
111 - }
112 -}
113 -
114 -func TestTeardownCalledOnce(t *testing.T) {
115 - a := setupHierarchy(Background())
116 -
117 - onlyOnce := func() func() error {
118 - count := 0
119 - return func() error {
120 - count++
121 - if count > 1 {
122 - t.Error("called", count, "times")
123 - }
124 - return nil
125 - }
126 - }
127 -
128 - a.SetTeardown(onlyOnce())
129 - a.c[0].SetTeardown(onlyOnce())
130 - a.c[0].c[0].SetTeardown(onlyOnce())
131 - a.c[0].c[1].SetTeardown(onlyOnce())
132 - a.c[1].SetTeardown(onlyOnce())
133 - a.c[1].c[0].SetTeardown(onlyOnce())
134 - a.c[1].c[1].SetTeardown(onlyOnce())
135 -
136 - a.c[0].c[0].Close()
137 - a.c[0].c[0].Close()
138 - a.c[0].c[0].Close()
139 - a.c[0].c[0].Close()
140 - a.c[0].Close()
141 - a.c[0].Close()
142 - a.c[0].Close()
143 - a.c[0].Close()
144 - a.Close()
145 - a.Close()
146 - a.Close()
147 - a.Close()
148 - a.c[1].Close()
149 - a.c[1].Close()
150 - a.c[1].Close()
151 - a.c[1].Close()
152 -}
153 -
154 -func TestOnClosedAll(t *testing.T) {
155 -
156 - Q := make(chan string, 10)
157 - p := WithParent(Background())
158 - a := setupHierarchy(p)
159 -
160 - go onClosedStr(Q, "0", a.c[0])
161 - go onClosedStr(Q, "10", a.c[1].c[0])
162 - go onClosedStr(Q, "", a)
163 - go onClosedStr(Q, "00", a.c[0].c[0])
164 - go onClosedStr(Q, "1", a.c[1])
165 - go onClosedStr(Q, "01", a.c[0].c[1])
166 - go onClosedStr(Q, "11", a.c[1].c[1])
167 -
168 - go p.Close()
169 -
170 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
171 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
172 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
173 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
174 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
175 - testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
176 -}
177 -
178 -func TestOnClosedLeaves(t *testing.T) {
179 -
180 - Q := make(chan string, 10)
181 - p := WithParent(Background())
182 - a := setupHierarchy(p)
183 -
184 - go onClosedStr(Q, "0", a.c[0])
185 - go onClosedStr(Q, "10", a.c[1].c[0])
186 - go onClosedStr(Q, "", a)
187 - go onClosedStr(Q, "00", a.c[0].c[0])
188 - go onClosedStr(Q, "1", a.c[1])
189 - go onClosedStr(Q, "01", a.c[0].c[1])
190 - go onClosedStr(Q, "11", a.c[1].c[1])
191 -
192 - go a.c[0].Close()
193 - testStrs(t, Q, "00", "01", "0")
194 - testStrs(t, Q, "00", "01", "0")
195 - testStrs(t, Q, "00", "01", "0")
196 -
197 - go a.c[1].Close()
198 - testStrs(t, Q, "10", "11", "1")
199 - testStrs(t, Q, "10", "11", "1")
200 - testStrs(t, Q, "10", "11", "1")
201 -
202 - go p.Close()
203 - testStrs(t, Q, "")
204 -}
205 -
206 -func TestWaitFor(t *testing.T) {
207 -
208 - Q := make(chan string, 5)
209 - a := WithParent(Background())
210 - b := WithParent(Background())
211 - c := WithParent(Background())
212 - d := WithParent(Background())
213 - e := WithParent(Background())
214 -
215 - go onClosedStr(Q, "a", a)
216 - go onClosedStr(Q, "b", b)
217 - go onClosedStr(Q, "c", c)
218 - go onClosedStr(Q, "d", d)
219 - go onClosedStr(Q, "e", e)
220 -
221 - testNone(t, Q)
222 - a.WaitFor(b)
223 - a.WaitFor(c)
224 - b.WaitFor(d)
225 - e.WaitFor(d)
226 - testNone(t, Q)
227 -
228 - go a.Close() // should do nothing.
229 - testNone(t, Q)
230 -
231 - go e.Close()
232 - testNone(t, Q)
233 -
234 - d.Close()
235 - testStrs(t, Q, "d", "e")
236 - testStrs(t, Q, "d", "e")
237 -
238 - c.Close()
239 - testStrs(t, Q, "c")
240 -
241 - b.Close()
242 - testStrs(t, Q, "a", "b")
243 - testStrs(t, Q, "a", "b")
244 -}
245 -
246 -func TestAddChildNoWait(t *testing.T) {
247 -
248 - Q := make(chan string, 5)
249 - a := WithParent(Background())
250 - b := WithParent(Background())
251 - c := WithParent(Background())
252 - d := WithParent(Background())
253 - e := WithParent(Background())
254 -
255 - go onClosedStr(Q, "a", a)
256 - go onClosedStr(Q, "b", b)
257 - go onClosedStr(Q, "c", c)
258 - go onClosedStr(Q, "d", d)
259 - go onClosedStr(Q, "e", e)
260 -
261 - testNone(t, Q)
262 - a.AddChildNoWait(b)
263 - a.AddChildNoWait(c)
264 - b.AddChildNoWait(d)
265 - e.AddChildNoWait(d)
266 - testNone(t, Q)
267 -
268 - b.Close()
269 - testStrs(t, Q, "b", "d")
270 - testStrs(t, Q, "b", "d")
271 -
272 - a.Close()
273 - testStrs(t, Q, "a", "c")
274 - testStrs(t, Q, "a", "c")
275 -
276 - e.Close()
277 - testStrs(t, Q, "e")
278 -}
279 -
280 -func TestAddChild(t *testing.T) {
281 -
282 - a := WithParent(Background())
283 - b := WithParent(Background())
284 - c := WithParent(Background())
285 - d := WithParent(Background())
286 - e := WithParent(Background())
287 - Q := make(chan string, 5)
288 -
289 - go onClosedStr(Q, "a", a)
290 - go onClosedStr(Q, "b", b)
291 - go onClosedStr(Q, "c", c)
292 - go onClosedStr(Q, "d", d)
293 - go onClosedStr(Q, "e", e)
294 -
295 - testNone(t, Q)
296 - a.AddChild(b)
297 - a.AddChild(c)
298 - b.AddChild(d)
299 - e.AddChild(d)
300 - testNone(t, Q)
301 -
302 - go b.Close()
303 - d.Close()
304 - testStrs(t, Q, "b", "d")
305 - testStrs(t, Q, "b", "d")
306 -
307 - go a.Close()
308 - c.Close()
309 - testStrs(t, Q, "a", "c")
310 - testStrs(t, Q, "a", "c")
311 -
312 - e.Close()
313 - testStrs(t, Q, "e")
314 -}
315 -
316 -func TestGoChildrenClose(t *testing.T) {
317 -
318 - var a, b, c, d, e Process
319 - var ready = make(chan struct{})
320 - var bWait = make(chan struct{})
321 - var cWait = make(chan struct{})
322 - var dWait = make(chan struct{})
323 - var eWait = make(chan struct{})
324 -
325 - a = WithParent(Background())
326 - a.Go(func(p Process) {
327 - b = p
328 - b.Go(func(p Process) {
329 - c = p
330 - ready <- struct{}{}
331 - <-cWait
332 - })
333 - ready <- struct{}{}
334 - <-bWait
335 - })
336 - a.Go(func(p Process) {
337 - d = p
338 - d.Go(func(p Process) {
339 - e = p
340 - ready <- struct{}{}
341 - <-eWait
342 - })
343 - ready <- struct{}{}
344 - <-dWait
345 - })
346 -
347 - <-ready
348 - <-ready
349 - <-ready
350 - <-ready
351 -
352 - Q := make(chan string, 5)
353 -
354 - go onClosedStr(Q, "a", a)
355 - go onClosedStr(Q, "b", b)
356 - go onClosedStr(Q, "c", c)
357 - go onClosedStr(Q, "d", d)
358 - go onClosedStr(Q, "e", e)
359 -
360 - testNone(t, Q)
361 - go a.Close()
362 - testNone(t, Q)
363 -
364 - bWait <- struct{}{} // relase b
365 - go b.Close()
366 - testNone(t, Q)
367 -
368 - cWait <- struct{}{} // relase c
369 - <-c.Closed()
370 - <-b.Closed()
371 - testStrs(t, Q, "b", "c")
372 - testStrs(t, Q, "b", "c")
373 -
374 - eWait <- struct{}{} // release e
375 - <-e.Closed()
376 - testStrs(t, Q, "e")
377 -
378 - dWait <- struct{}{} // releasse d
379 - <-d.Closed()
380 - <-a.Closed()
381 - testStrs(t, Q, "a", "d")
382 - testStrs(t, Q, "a", "d")
383 -}
384 -
385 -func TestCloseAfterChildren(t *testing.T) {
386 -
387 - var a, b, c, d, e Process
388 -
389 - var ready = make(chan struct{})
390 -
391 - a = WithParent(Background())
392 - a.Go(func(p Process) {
393 - b = p
394 - b.Go(func(p Process) {
395 - c = p
396 - ready <- struct{}{}
397 - <-p.Closing() // wait till we're told to close (parents mustnt)
398 - })
399 - ready <- struct{}{}
400 - // <-p.Closing() // will CloseAfterChildren
401 - })
402 - a.Go(func(p Process) {
403 - d = p
404 - d.Go(func(p Process) {
405 - e = p
406 - ready <- struct{}{}
407 - <-p.Closing() // wait till we're told to close (parents mustnt)
408 - })
409 - ready <- struct{}{}
410 - <-p.Closing()
411 - })
412 -
413 - <-ready
414 - <-ready
415 - <-ready
416 - <-ready
417 -
418 - Q := make(chan string, 5)
419 -
420 - go onClosedStr(Q, "a", a)
421 - go onClosedStr(Q, "b", b)
422 - go onClosedStr(Q, "c", c)
423 - go onClosedStr(Q, "d", d)
424 - go onClosedStr(Q, "e", e)
425 -
426 - aDone := make(chan struct{})
427 - bDone := make(chan struct{})
428 -
429 - t.Log("test none when waiting on a")
430 - testNone(t, Q)
431 - go func() {
432 - a.CloseAfterChildren()
433 - aDone <- struct{}{}
434 - }()
435 - testNone(t, Q)
436 -
437 - t.Log("test none when waiting on b")
438 - go func() {
439 - b.CloseAfterChildren()
440 - bDone <- struct{}{}
441 - }()
442 - testNone(t, Q)
443 -
444 - c.Close()
445 - <-bDone
446 - <-b.Closed()
447 - testStrs(t, Q, "b", "c")
448 - testStrs(t, Q, "b", "c")
449 -
450 - e.Close()
451 - testStrs(t, Q, "e")
452 -
453 - d.Close()
454 - <-aDone
455 - <-a.Closed()
456 - testStrs(t, Q, "a", "d")
457 - testStrs(t, Q, "a", "d")
458 -}
459 -
460 -func TestGoClosing(t *testing.T) {
461 -
462 - var ready = make(chan struct{})
463 - a := WithParent(Background())
464 - a.Go(func(p Process) {
465 -
466 - // this should be fine.
467 - a.Go(func(p Process) {
468 - ready <- struct{}{}
469 - })
470 -
471 - // set a to close. should not fully close until after this func returns.
472 - go a.Close()
473 -
474 - // wait until a is marked as closing
475 - <-a.Closing()
476 -
477 - // this should also be fine.
478 - a.Go(func(p Process) {
479 -
480 - select {
481 - case <-p.Closing():
482 - // p should be marked as closing
483 - default:
484 - t.Error("not marked closing when it should be.")
485 - }
486 -
487 - ready <- struct{}{}
488 - })
489 -
490 - ready <- struct{}{}
491 - })
492 -
493 - <-ready
494 - <-ready
495 - <-ready
496 -}
497 -
498 -func TestBackground(t *testing.T) {
499 - // test it hangs indefinitely:
500 - b := Background()
501 - go b.Close()
502 -
503 - select {
504 - case <-b.Closing():
505 - t.Error("b.Closing() closed :(")
506 - default:
507 - }
508 -}
509 -
510 -func TestWithSignals(t *testing.T) {
511 - p := WithSignals(syscall.SIGABRT)
512 - testNotClosed(t, p)
513 -
514 - syscall.Kill(syscall.Getpid(), syscall.SIGABRT)
515 - testClosed(t, p)
516 -}
517 -
518 -func TestMemoryLeak(t *testing.T) {
519 - iters := 100
520 - fanout := 10
521 - P := newProcess(nil)
522 - var memories []float32
523 -
524 - measure := func(str string) float32 {
525 - s := new(runtime.MemStats)
526 - runtime.ReadMemStats(s)
527 - //fmt.Printf("%d ", s.HeapObjects)
528 - //fmt.Printf("%d ", len(P.children))
529 - //fmt.Printf("%d ", runtime.NumGoroutine())
530 - //fmt.Printf("%s: %dk\n", str, s.HeapAlloc/1000)
531 - return float32(s.HeapAlloc) / 1000
532 - }
533 -
534 - spawn := func() []Process {
535 - var ps []Process
536 - // Spawn processes
537 - for i := 0; i < fanout; i++ {
538 - p := WithParent(P)
539 - ps = append(ps, p)
540 -
541 - for i := 0; i < fanout; i++ {
542 - p2 := WithParent(p)
543 - ps = append(ps, p2)
544 -
545 - for i := 0; i < fanout; i++ {
546 - p3 := WithParent(p2)
547 - ps = append(ps, p3)
548 - }
549 - }
550 - }
551 - return ps
552 - }
553 -
554 - // Read initial memory stats
555 - measure("initial")
556 - for i := 0; i < iters; i++ {
557 - ps := spawn()
558 - //measure("alloc") // read after alloc
559 -
560 - // Close all processes
561 - for _, p := range ps {
562 - p.Close()
563 - <-p.Closed()
564 - }
565 - ps = nil
566 -
567 - //measure("dealloc") // read after dealloc, but before gc
568 -
569 - // wait until all/most goroutines finish
570 - <-time.After(time.Millisecond)
571 -
572 - // Run GC
573 - runtime.GC()
574 - memories = append(memories, measure("gc")) // read after gc
575 - }
576 -
577 - memoryInit := memories[10]
578 - percentGrowth := 100 * (memories[len(memories)-1] - memoryInit) / memoryInit
579 - fmt.Printf("Memory growth after %d iteration with each %d processes: %.2f%% after %dk\n", iters, fanout*fanout*fanout, percentGrowth, int(memoryInit))
580 -
581 -}
582 -
583 -func testClosing(t *testing.T, p Process) {
584 - select {
585 - case <-p.Closing():
586 - case <-time.After(50 * time.Millisecond):
587 - t.Fatal("should be closing")
588 - }
589 -}
590 -
591 -func testNotClosing(t *testing.T, p Process) {
592 - select {
593 - case <-p.Closing():
594 - t.Fatal("should not be closing")
595 - case <-p.Closed():
596 - t.Fatal("should not be closed")
597 - default:
598 - }
599 -}
600 -
601 -func testClosed(t *testing.T, p Process) {
602 - select {
603 - case <-p.Closed():
604 - case <-time.After(50 * time.Millisecond):
605 - t.Fatal("should be closed")
606 - }
607 -}
608 -
609 -func testNotClosed(t *testing.T, p Process) {
610 - select {
611 - case <-p.Closed():
612 - t.Fatal("should not be closed")
613 - case <-time.After(50 * time.Millisecond):
614 - }
615 -}
616 -
617 -func testNone(t *testing.T, c <-chan string) {
618 - select {
619 - case out := <-c:
620 - t.Fatal("none should be closed", out)
621 - default:
622 - }
623 -}
624 -
625 -func testStrs(t *testing.T, Q <-chan string, ss ...string) {
626 - s1 := <-Q
627 - for _, s2 := range ss {
628 - if s1 == s2 {
629 - return
630 - }
631 - }
632 - t.Error("context not in group:", s1, ss)
633 -}
634 -
635 -func onClosedStr(Q chan<- string, s string, p Process) {
636 - <-p.Closed()
637 - Q <- s
638 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go deleted
-271
@@ -1,271 +0,0 @@
1 -package goprocess
2 -
3 -import (
4 - "sync"
5 -)
6 -
7 -// process implements Process
8 -type process struct {
9 - children map[*processLink]struct{} // process to close with us
10 - waitfors map[*processLink]struct{} // process to only wait for
11 - waiters []*processLink // processes that wait for us. for gc.
12 -
13 - teardown TeardownFunc // called to run the teardown logic.
14 - waiting chan struct{} // closed when CloseAfterChildrenClosed is called.
15 - closing chan struct{} // closed once close starts.
16 - closed chan struct{} // closed once close is done.
17 - closeErr error // error to return to clients of Close()
18 -
19 - sync.Mutex
20 -}
21 -
22 -// newProcess constructs and returns a Process.
23 -// It will call tf TeardownFunc exactly once:
24 -// **after** all children have fully Closed,
25 -// **after** entering <-Closing(), and
26 -// **before** <-Closed().
27 -func newProcess(tf TeardownFunc) *process {
28 - return &process{
29 - teardown: tf,
30 - closed: make(chan struct{}),
31 - closing: make(chan struct{}),
32 - waitfors: make(map[*processLink]struct{}),
33 - children: make(map[*processLink]struct{}),
34 - }
35 -}
36 -
37 -func (p *process) WaitFor(q Process) {
38 - if q == nil {
39 - panic("waiting for nil process")
40 - }
41 -
42 - p.Lock()
43 -
44 - select {
45 - case <-p.Closed():
46 - panic("Process cannot wait after being closed")
47 - default:
48 - }
49 -
50 - pl := newProcessLink(p, q)
51 - p.waitfors[pl] = struct{}{}
52 - p.Unlock()
53 - go pl.AddToChild()
54 -}
55 -
56 -func (p *process) AddChildNoWait(child Process) {
57 - if child == nil {
58 - panic("adding nil child process")
59 - }
60 -
61 - p.Lock()
62 -
63 - select {
64 - case <-p.Closed():
65 - panic("Process cannot add children after being closed")
66 - case <-p.Closing():
67 - go child.Close()
68 - default:
69 - }
70 -
71 - pl := newProcessLink(p, child)
72 - p.children[pl] = struct{}{}
73 - p.Unlock()
74 - go pl.AddToChild()
75 -}
76 -
77 -func (p *process) AddChild(child Process) {
78 - if child == nil {
79 - panic("adding nil child process")
80 - }
81 -
82 - p.Lock()
83 -
84 - select {
85 - case <-p.Closed():
86 - panic("Process cannot add children after being closed")
87 - case <-p.Closing():
88 - go child.Close()
89 - default:
90 - }
91 -
92 - pl := newProcessLink(p, child)
93 - if p.waitfors != nil { // if p.waitfors hasn't been set nil
94 - p.waitfors[pl] = struct{}{}
95 - }
96 - if p.children != nil { // if p.children hasn't been set nil
97 - p.children[pl] = struct{}{}
98 - }
99 - p.Unlock()
100 - go pl.AddToChild()
101 -}
102 -
103 -func (p *process) Go(f ProcessFunc) Process {
104 - child := newProcess(nil)
105 - waitFor := newProcess(nil)
106 - child.WaitFor(waitFor) // prevent child from closing
107 -
108 - // add child last, to prevent a closing parent from
109 - // closing all of them prematurely, before running the func.
110 - p.AddChild(child)
111 - go func() {
112 - f(child)
113 - waitFor.Close() // allow child to close.
114 - child.CloseAfterChildren() // close to tear down.
115 - }()
116 - return child
117 -}
118 -
119 -// SetTeardown to assign a teardown function
120 -func (p *process) SetTeardown(tf TeardownFunc) {
121 - if tf == nil {
122 - panic("cannot set nil TeardownFunc")
123 - }
124 -
125 - p.Lock()
126 - if p.teardown != nil {
127 - panic("cannot SetTeardown twice")
128 - }
129 -
130 - p.teardown = tf
131 - select {
132 - case <-p.Closed():
133 - p.closeErr = tf()
134 - default:
135 - }
136 - p.Unlock()
137 -}
138 -
139 -// Close is the external close function.
140 -// it's a wrapper around internalClose that waits on Closed()
141 -func (p *process) Close() error {
142 - p.Lock()
143 -
144 - // if already closing, or closed, get out. (but wait!)
145 - select {
146 - case <-p.Closing():
147 - p.Unlock()
148 - <-p.Closed()
149 - return p.closeErr
150 - default:
151 - }
152 -
153 - p.doClose()
154 - p.Unlock()
155 - return p.closeErr
156 -}
157 -
158 -func (p *process) Closing() <-chan struct{} {
159 - return p.closing
160 -}
161 -
162 -func (p *process) Closed() <-chan struct{} {
163 - return p.closed
164 -}
165 -
166 -func (p *process) Err() error {
167 - <-p.Closed()
168 - return p.closeErr
169 -}
170 -
171 -// the _actual_ close process.
172 -func (p *process) doClose() {
173 - // this function is only be called once (protected by p.Lock()).
174 - // and it will panic (on closing channels) otherwise.
175 -
176 - close(p.closing) // signal that we're shutting down (Closing)
177 -
178 - for len(p.children) > 0 || len(p.waitfors) > 0 {
179 - for plc, _ := range p.children {
180 - child := plc.Child()
181 - if child != nil { // check because child may already have been removed.
182 - go child.Close() // force all children to shut down
183 - }
184 - plc.ParentClear()
185 - }
186 - p.children = nil // clear them. release memory.
187 -
188 - // we must be careful not to iterate over waitfors directly, as it may
189 - // change under our feet.
190 - wf := p.waitfors
191 - p.waitfors = nil // clear them. release memory.
192 - for w, _ := range wf {
193 - // Here, we wait UNLOCKED, so that waitfors who are in the middle of
194 - // adding a child to us can finish. we will immediately close the child.
195 - p.Unlock()
196 - <-w.ChildClosed() // wait till all waitfors are fully closed (before teardown)
197 - p.Lock()
198 - w.ParentClear()
199 - }
200 - }
201 -
202 - if p.teardown != nil {
203 - p.closeErr = p.teardown() // actually run the close logic (ok safe to teardown)
204 - }
205 - close(p.closed) // signal that we're shut down (Closed)
206 -
207 - // go remove all the parents from the process links. optimization.
208 - go func(waiters []*processLink) {
209 - for _, pl := range waiters {
210 - pl.ClearChild()
211 - pr, ok := pl.Parent().(*process)
212 - if !ok {
213 - // parent has already been called to close
214 - continue
215 - }
216 - pr.Lock()
217 - delete(pr.waitfors, pl)
218 - delete(pr.children, pl)
219 - pr.Unlock()
220 - }
221 - }(p.waiters) // pass in so
222 - p.waiters = nil // clear them. release memory.
223 -}
224 -
225 -// We will only wait on the children we have now.
226 -// We will not wait on children added subsequently.
227 -// this may change in the future.
228 -func (p *process) CloseAfterChildren() error {
229 - p.Lock()
230 - select {
231 - case <-p.Closed():
232 - p.Unlock()
233 - return p.Close() // get error. safe, after p.Closed()
234 - case <-p.waiting: // already called it.
235 - p.Unlock()
236 - <-p.Closed()
237 - return p.Close() // get error. safe, after p.Closed()
238 - default:
239 - }
240 - p.Unlock()
241 -
242 - // here only from one goroutine.
243 -
244 - nextToWaitFor := func() Process {
245 - p.Lock()
246 - defer p.Unlock()
247 - for e, _ := range p.waitfors {
248 - c := e.Child()
249 - if c == nil {
250 - continue
251 - }
252 -
253 - select {
254 - case <-c.Closed():
255 - default:
256 - return c
257 - }
258 - }
259 - return nil
260 - }
261 -
262 - // wait for all processes we're waiting for are closed.
263 - // the semantics here are simple: we will _only_ close
264 - // if there are no processes currently waiting for.
265 - for next := nextToWaitFor(); next != nil; next = nextToWaitFor() {
266 - <-next.Closed()
267 - }
268 -
269 - // YAY! we're done. close
270 - return p.Close()
271 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/link.go deleted
-121
@@ -1,121 +0,0 @@
1 -package goprocess
2 -
3 -import (
4 - "sync"
5 -)
6 -
7 -// closedCh is an alread-closed channel. used to return
8 -// in cases where we already know a channel is closed.
9 -var closedCh chan struct{}
10 -
11 -func init() {
12 - closedCh = make(chan struct{})
13 - close(closedCh)
14 -}
15 -
16 -// a processLink is an internal bookkeeping datastructure.
17 -// it's used to form a relationship between two processes.
18 -// It is mostly for keeping memory usage down (letting
19 -// children close and be garbage-collected).
20 -type processLink struct {
21 - // guards all fields.
22 - // DO NOT HOLD while holding process locks.
23 - // it may be slow, and could deadlock if not careful.
24 - sync.Mutex
25 - parent Process
26 - child Process
27 -}
28 -
29 -func newProcessLink(p, c Process) *processLink {
30 - return &processLink{
31 - parent: p,
32 - child: c,
33 - }
34 -}
35 -
36 -// Closing returns whether the child is closing
37 -func (pl *processLink) ChildClosing() <-chan struct{} {
38 - // grab a hold of it, and unlock, as .Closing may block.
39 - pl.Lock()
40 - child := pl.child
41 - pl.Unlock()
42 -
43 - if child == nil { // already closed? memory optimization.
44 - return closedCh
45 - }
46 - return child.Closing()
47 -}
48 -
49 -func (pl *processLink) ChildClosed() <-chan struct{} {
50 - // grab a hold of it, and unlock, as .Closed may block.
51 - pl.Lock()
52 - child := pl.child
53 - pl.Unlock()
54 -
55 - if child == nil { // already closed? memory optimization.
56 - return closedCh
57 - }
58 - return child.Closed()
59 -}
60 -
61 -func (pl *processLink) ChildClose() {
62 - // grab a hold of it, and unlock, as .Closed may block.
63 - pl.Lock()
64 - child := pl.child
65 - pl.Unlock()
66 -
67 - if child != nil { // already closed? memory optimization.
68 - child.Close()
69 - }
70 -}
71 -
72 -func (pl *processLink) ClearChild() {
73 - pl.Lock()
74 - pl.child = nil
75 - pl.Unlock()
76 -}
77 -
78 -func (pl *processLink) ParentClear() {
79 - pl.Lock()
80 - pl.parent = nil
81 - pl.Unlock()
82 -}
83 -
84 -func (pl *processLink) Child() Process {
85 - pl.Lock()
86 - defer pl.Unlock()
87 - return pl.child
88 -}
89 -
90 -func (pl *processLink) Parent() Process {
91 - pl.Lock()
92 - defer pl.Unlock()
93 - return pl.parent
94 -}
95 -
96 -func (pl *processLink) AddToChild() {
97 - cp := pl.Child()
98 -
99 - // is it a *process ? if not... panic.
100 - c, ok := cp.(*process)
101 - if !ok {
102 - panic("goprocess does not yet support other process impls.")
103 - }
104 -
105 - // first, is it Closed?
106 - c.Lock()
107 - select {
108 - case <-c.Closed():
109 - c.Unlock()
110 -
111 - // already closed. must not add.
112 - // we must clear it, though. do so without the lock.
113 - pl.ClearChild()
114 - return
115 -
116 - default:
117 - // put the process link into q's waiters
118 - c.waiters = append(c.waiters, pl)
119 - c.Unlock()
120 - }
121 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/periodic/README.md deleted
-4
@@ -1,4 +0,0 @@
1 -# goprocess/periodic - periodic process creation
2 -
3 -- goprocess: https://github.com/jbenet/goprocess
4 -- Godoc: https://godoc.org/github.com/jbenet/goprocess/periodic
Godeps/_workspace/src/github.com/jbenet/goprocess/periodic/examples_test.go deleted
-85
@@ -1,85 +0,0 @@
1 -package periodicproc_test
2 -
3 -import (
4 - "fmt"
5 - "time"
6 -
7 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 - periodicproc "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic"
9 -)
10 -
11 -func ExampleEvery() {
12 - tock := make(chan struct{})
13 -
14 - i := 0
15 - p := periodicproc.Every(time.Second, func(proc goprocess.Process) {
16 - tock <- struct{}{}
17 - fmt.Printf("hello %d\n", i)
18 - i++
19 - })
20 -
21 - <-tock
22 - <-tock
23 - <-tock
24 - p.Close()
25 -
26 - // Output:
27 - // hello 0
28 - // hello 1
29 - // hello 2
30 -}
31 -
32 -func ExampleTick() {
33 - p := periodicproc.Tick(time.Second, func(proc goprocess.Process) {
34 - fmt.Println("tick")
35 - })
36 -
37 - <-time.After(3*time.Second + 500*time.Millisecond)
38 - p.Close()
39 -
40 - // Output:
41 - // tick
42 - // tick
43 - // tick
44 -}
45 -
46 -func ExampleTickGo() {
47 -
48 - // with TickGo, execution is not rate limited,
49 - // there can be many in-flight simultaneously
50 -
51 - wait := make(chan struct{})
52 - p := periodicproc.TickGo(time.Second, func(proc goprocess.Process) {
53 - fmt.Println("tick")
54 - <-wait
55 - })
56 -
57 - <-time.After(3*time.Second + 500*time.Millisecond)
58 -
59 - wait <- struct{}{}
60 - wait <- struct{}{}
61 - wait <- struct{}{}
62 - p.Close() // blocks us until all children are closed.
63 -
64 - // Output:
65 - // tick
66 - // tick
67 - // tick
68 -}
69 -
70 -func ExampleOnSignal() {
71 - sig := make(chan struct{})
72 - p := periodicproc.OnSignal(sig, func(proc goprocess.Process) {
73 - fmt.Println("fire!")
74 - })
75 -
76 - sig <- struct{}{}
77 - sig <- struct{}{}
78 - sig <- struct{}{}
79 - p.Close()
80 -
81 - // Output:
82 - // fire!
83 - // fire!
84 - // fire!
85 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/periodic/periodic.go deleted
-232
@@ -1,232 +0,0 @@
1 -// Package periodic is part of github.com/jbenet/goprocess.
2 -// It provides a simple periodic processor that calls a function
3 -// periodically based on some options.
4 -//
5 -// For example:
6 -//
7 -// // use a time.Duration
8 -// p := periodicproc.Every(time.Second, func(proc goprocess.Process) {
9 -// fmt.Printf("the time is %s and all is well", time.Now())
10 -// })
11 -//
12 -// <-time.After(5*time.Second)
13 -// p.Close()
14 -//
15 -// // use a time.Time channel (like time.Ticker)
16 -// p := periodicproc.Tick(time.Tick(time.Second), func(proc goprocess.Process) {
17 -// fmt.Printf("the time is %s and all is well", time.Now())
18 -// })
19 -//
20 -// <-time.After(5*time.Second)
21 -// p.Close()
22 -//
23 -// // or arbitrary signals
24 -// signal := make(chan struct{})
25 -// p := periodicproc.OnSignal(signal, func(proc goprocess.Process) {
26 -// fmt.Printf("the time is %s and all is well", time.Now())
27 -// })
28 -//
29 -// signal<- struct{}{}
30 -// signal<- struct{}{}
31 -// <-time.After(5 * time.Second)
32 -// signal<- struct{}{}
33 -// p.Close()
34 -//
35 -package periodicproc
36 -
37 -import (
38 - "time"
39 -
40 - gp "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
41 -)
42 -
43 -// Every calls the given ProcessFunc at periodic intervals. Internally, it uses
44 -// <-time.After(interval), so it will have the behavior of waiting _at least_
45 -// interval in between calls. If you'd prefer the time.Ticker behavior, use
46 -// periodicproc.Tick instead.
47 -// This is sequentially rate limited, only one call will be in-flight at a time.
48 -func Every(interval time.Duration, procfunc gp.ProcessFunc) gp.Process {
49 - return gp.Go(func(proc gp.Process) {
50 - for {
51 - select {
52 - case <-time.After(interval):
53 - select {
54 - case <-proc.Go(procfunc).Closed(): // spin it out as a child, and wait till it's done.
55 - case <-proc.Closing(): // we're told to close
56 - return
57 - }
58 - case <-proc.Closing(): // we're told to close
59 - return
60 - }
61 - }
62 - })
63 -}
64 -
65 -// EveryGo calls the given ProcessFunc at periodic intervals. Internally, it uses
66 -// <-time.After(interval)
67 -// This is not rate limited, multiple calls could be in-flight at the same time.
68 -func EveryGo(interval time.Duration, procfunc gp.ProcessFunc) gp.Process {
69 - return gp.Go(func(proc gp.Process) {
70 - for {
71 - select {
72 - case <-time.After(interval):
73 - proc.Go(procfunc)
74 - case <-proc.Closing(): // we're told to close
75 - return
76 - }
77 - }
78 - })
79 -}
80 -
81 -// Tick constructs a ticker with interval, and calls the given ProcessFunc every
82 -// time the ticker fires.
83 -// This is sequentially rate limited, only one call will be in-flight at a time.
84 -//
85 -// p := periodicproc.Tick(time.Second, func(proc goprocess.Process) {
86 -// fmt.Println("fire!")
87 -// })
88 -//
89 -// <-time.After(3 * time.Second)
90 -// p.Close()
91 -//
92 -// // Output:
93 -// // fire!
94 -// // fire!
95 -// // fire!
96 -func Tick(interval time.Duration, procfunc gp.ProcessFunc) gp.Process {
97 - return gp.Go(func(proc gp.Process) {
98 - ticker := time.NewTicker(interval)
99 - callOnTicker(ticker.C, procfunc)(proc)
100 - ticker.Stop()
101 - })
102 -}
103 -
104 -// TickGo constructs a ticker with interval, and calls the given ProcessFunc every
105 -// time the ticker fires.
106 -// This is not rate limited, multiple calls could be in-flight at the same time.
107 -//
108 -// p := periodicproc.TickGo(time.Second, func(proc goprocess.Process) {
109 -// fmt.Println("fire!")
110 -// <-time.After(10 * time.Second) // will not block sequential execution
111 -// })
112 -//
113 -// <-time.After(3 * time.Second)
114 -// p.Close()
115 -//
116 -// // Output:
117 -// // fire!
118 -// // fire!
119 -// // fire!
120 -func TickGo(interval time.Duration, procfunc gp.ProcessFunc) gp.Process {
121 - return gp.Go(func(proc gp.Process) {
122 - ticker := time.NewTicker(interval)
123 - goCallOnTicker(ticker.C, procfunc)(proc)
124 - ticker.Stop()
125 - })
126 -}
127 -
128 -// Ticker calls the given ProcessFunc every time the ticker fires.
129 -// This is sequentially rate limited, only one call will be in-flight at a time.
130 -func Ticker(ticker <-chan time.Time, procfunc gp.ProcessFunc) gp.Process {
131 - return gp.Go(callOnTicker(ticker, procfunc))
132 -}
133 -
134 -// TickerGo calls the given ProcessFunc every time the ticker fires.
135 -// This is not rate limited, multiple calls could be in-flight at the same time.
136 -func TickerGo(ticker <-chan time.Time, procfunc gp.ProcessFunc) gp.Process {
137 - return gp.Go(goCallOnTicker(ticker, procfunc))
138 -}
139 -
140 -func callOnTicker(ticker <-chan time.Time, pf gp.ProcessFunc) gp.ProcessFunc {
141 - return func(proc gp.Process) {
142 - for {
143 - select {
144 - case <-ticker:
145 - select {
146 - case <-proc.Go(pf).Closed(): // spin it out as a child, and wait till it's done.
147 - case <-proc.Closing(): // we're told to close
148 - return
149 - }
150 - case <-proc.Closing(): // we're told to close
151 - return
152 - }
153 - }
154 - }
155 -}
156 -
157 -func goCallOnTicker(ticker <-chan time.Time, pf gp.ProcessFunc) gp.ProcessFunc {
158 - return func(proc gp.Process) {
159 - for {
160 - select {
161 - case <-ticker:
162 - proc.Go(pf)
163 - case <-proc.Closing(): // we're told to close
164 - return
165 - }
166 - }
167 - }
168 -}
169 -
170 -// OnSignal calls the given ProcessFunc every time the signal fires, and waits for it to exit.
171 -// This is sequentially rate limited, only one call will be in-flight at a time.
172 -//
173 -// sig := make(chan struct{})
174 -// p := periodicproc.OnSignal(sig, func(proc goprocess.Process) {
175 -// fmt.Println("fire!")
176 -// <-time.After(time.Second) // delays sequential execution by 1 second
177 -// })
178 -//
179 -// sig<- struct{}
180 -// sig<- struct{}
181 -// sig<- struct{}
182 -//
183 -// // Output:
184 -// // fire!
185 -// // fire!
186 -// // fire!
187 -func OnSignal(sig <-chan struct{}, procfunc gp.ProcessFunc) gp.Process {
188 - return gp.Go(func(proc gp.Process) {
189 - for {
190 - select {
191 - case <-sig:
192 - select {
193 - case <-proc.Go(procfunc).Closed(): // spin it out as a child, and wait till it's done.
194 - case <-proc.Closing(): // we're told to close
195 - return
196 - }
197 - case <-proc.Closing(): // we're told to close
198 - return
199 - }
200 - }
201 - })
202 -}
203 -
204 -// OnSignalGo calls the given ProcessFunc every time the signal fires.
205 -// This is not rate limited, multiple calls could be in-flight at the same time.
206 -//
207 -// sig := make(chan struct{})
208 -// p := periodicproc.OnSignalGo(sig, func(proc goprocess.Process) {
209 -// fmt.Println("fire!")
210 -// <-time.After(time.Second) // wont block execution
211 -// })
212 -//
213 -// sig<- struct{}
214 -// sig<- struct{}
215 -// sig<- struct{}
216 -//
217 -// // Output:
218 -// // fire!
219 -// // fire!
220 -// // fire!
221 -func OnSignalGo(sig <-chan struct{}, procfunc gp.ProcessFunc) gp.Process {
222 - return gp.Go(func(proc gp.Process) {
223 - for {
224 - select {
225 - case <-sig:
226 - proc.Go(procfunc)
227 - case <-proc.Closing(): // we're told to close
228 - return
229 - }
230 - }
231 - })
232 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/periodic/periodic_test.go deleted
-260
@@ -1,260 +0,0 @@
1 -package periodicproc
2 -
3 -import (
4 - "testing"
5 - "time"
6 -
7 - gp "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 - ci "gx/ipfs/QmZcUXuzsUSvxNj9pmU112V8L5kGUFMTYCdFcAbQ3Zj5cp/go-cienv"
9 -)
10 -
11 -var (
12 - grace = time.Millisecond * 5
13 - interval = time.Millisecond * 10
14 - timeout = time.Second * 5
15 -)
16 -
17 -func init() {
18 - if ci.IsRunning() {
19 - grace = time.Millisecond * 500
20 - interval = time.Millisecond * 1000
21 - timeout = time.Second * 15
22 - }
23 -}
24 -
25 -func between(min, diff, max time.Duration) bool {
26 - return min <= diff && diff <= max
27 -}
28 -
29 -func testBetween(t *testing.T, min, diff, max time.Duration) {
30 - if !between(min, diff, max) {
31 - t.Error("time diff incorrect:", min, diff, max)
32 - }
33 -}
34 -
35 -type intervalFunc func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process)
36 -
37 -func testSeq(t *testing.T, toTest intervalFunc) {
38 - t.Parallel()
39 -
40 - last := time.Now()
41 - times := make(chan time.Time, 10)
42 - p := toTest(times, nil)
43 -
44 - for i := 0; i < 5; i++ {
45 - next := <-times
46 - testBetween(t, interval-grace, next.Sub(last), interval+grace)
47 - last = next
48 - }
49 -
50 - go p.Close()
51 - select {
52 - case <-p.Closed():
53 - case <-time.After(timeout):
54 - t.Error("proc failed to close")
55 - }
56 -}
57 -
58 -func testSeqWait(t *testing.T, toTest intervalFunc) {
59 - t.Parallel()
60 -
61 - last := time.Now()
62 - times := make(chan time.Time, 10)
63 - wait := make(chan struct{})
64 - p := toTest(times, wait)
65 -
66 - for i := 0; i < 5; i++ {
67 - next := <-times
68 - testBetween(t, interval-grace, next.Sub(last), interval+grace)
69 -
70 - <-time.After(interval * 2) // make it wait.
71 - last = time.Now() // make it now (sequential)
72 - wait <- struct{}{} // release it.
73 - }
74 -
75 - go p.Close()
76 -
77 - select {
78 - case <-p.Closed():
79 - case <-time.After(timeout):
80 - t.Error("proc failed to close")
81 - }
82 -}
83 -
84 -func testSeqNoWait(t *testing.T, toTest intervalFunc) {
85 - t.Parallel()
86 -
87 - last := time.Now()
88 - times := make(chan time.Time, 10)
89 - wait := make(chan struct{})
90 - p := toTest(times, wait)
91 -
92 - for i := 0; i < 5; i++ {
93 - next := <-times
94 - testBetween(t, 0, next.Sub(last), interval+grace) // min of 0
95 -
96 - <-time.After(interval * 2) // make it wait.
97 - last = time.Now() // make it now (sequential)
98 - wait <- struct{}{} // release it.
99 - }
100 -
101 - go p.Close()
102 -
103 -end:
104 - select {
105 - case wait <- struct{}{}: // drain any extras.
106 - goto end
107 - case <-p.Closed():
108 - case <-time.After(timeout):
109 - t.Error("proc failed to close")
110 - }
111 -}
112 -
113 -func testParallel(t *testing.T, toTest intervalFunc) {
114 - t.Parallel()
115 -
116 - last := time.Now()
117 - times := make(chan time.Time, 10)
118 - wait := make(chan struct{})
119 - p := toTest(times, wait)
120 -
121 - for i := 0; i < 5; i++ {
122 - next := <-times
123 - testBetween(t, interval-grace, next.Sub(last), interval+grace)
124 - last = next
125 -
126 - <-time.After(interval * 2) // make it wait.
127 - wait <- struct{}{} // release it.
128 - }
129 -
130 - go p.Close()
131 -
132 -end:
133 - select {
134 - case wait <- struct{}{}: // drain any extras.
135 - goto end
136 - case <-p.Closed():
137 - case <-time.After(timeout):
138 - t.Error("proc failed to close")
139 - }
140 -}
141 -
142 -func TestEverySeq(t *testing.T) {
143 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
144 - return Every(interval, func(proc gp.Process) {
145 - times <- time.Now()
146 - })
147 - })
148 -}
149 -
150 -func TestEverySeqWait(t *testing.T) {
151 - testSeqWait(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
152 - return Every(interval, func(proc gp.Process) {
153 - times <- time.Now()
154 - select {
155 - case <-wait:
156 - case <-proc.Closing():
157 - }
158 - })
159 - })
160 -}
161 -
162 -func TestEveryGoSeq(t *testing.T) {
163 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
164 - return EveryGo(interval, func(proc gp.Process) {
165 - times <- time.Now()
166 - })
167 - })
168 -}
169 -
170 -func TestEveryGoSeqParallel(t *testing.T) {
171 - testParallel(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
172 - return EveryGo(interval, func(proc gp.Process) {
173 - times <- time.Now()
174 - select {
175 - case <-wait:
176 - case <-proc.Closing():
177 - }
178 - })
179 - })
180 -}
181 -
182 -func TestTickSeq(t *testing.T) {
183 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
184 - return Tick(interval, func(proc gp.Process) {
185 - times <- time.Now()
186 - })
187 - })
188 -}
189 -
190 -func TestTickSeqNoWait(t *testing.T) {
191 - testSeqNoWait(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
192 - return Tick(interval, func(proc gp.Process) {
193 - times <- time.Now()
194 - select {
195 - case <-wait:
196 - case <-proc.Closing():
197 - }
198 - })
199 - })
200 -}
201 -
202 -func TestTickGoSeq(t *testing.T) {
203 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
204 - return TickGo(interval, func(proc gp.Process) {
205 - times <- time.Now()
206 - })
207 - })
208 -}
209 -
210 -func TestTickGoSeqParallel(t *testing.T) {
211 - testParallel(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
212 - return TickGo(interval, func(proc gp.Process) {
213 - times <- time.Now()
214 - select {
215 - case <-wait:
216 - case <-proc.Closing():
217 - }
218 - })
219 - })
220 -}
221 -
222 -func TestTickerSeq(t *testing.T) {
223 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
224 - return Ticker(time.Tick(interval), func(proc gp.Process) {
225 - times <- time.Now()
226 - })
227 - })
228 -}
229 -
230 -func TestTickerSeqNoWait(t *testing.T) {
231 - testSeqNoWait(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
232 - return Ticker(time.Tick(interval), func(proc gp.Process) {
233 - times <- time.Now()
234 - select {
235 - case <-wait:
236 - case <-proc.Closing():
237 - }
238 - })
239 - })
240 -}
241 -
242 -func TestTickerGoSeq(t *testing.T) {
243 - testSeq(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
244 - return TickerGo(time.Tick(interval), func(proc gp.Process) {
245 - times <- time.Now()
246 - })
247 - })
248 -}
249 -
250 -func TestTickerGoParallel(t *testing.T) {
251 - testParallel(t, func(times chan<- time.Time, wait <-chan struct{}) (proc gp.Process) {
252 - return TickerGo(time.Tick(interval), func(proc gp.Process) {
253 - times <- time.Now()
254 - select {
255 - case <-wait:
256 - case <-proc.Closing():
257 - }
258 - })
259 - })
260 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/README.md deleted
-4
@@ -1,4 +0,0 @@
1 -# goprocess/ratelimit - ratelimit children creation
2 -
3 -- goprocess: https://github.com/jbenet/goprocess
4 -- Godoc: https://godoc.org/github.com/jbenet/goprocess/ratelimit
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/ratelimit.go deleted
-68
@@ -1,68 +0,0 @@
1 -// Package ratelimit is part of github.com/jbenet/goprocess.
2 -// It provides a simple process that ratelimits child creation.
3 -// This is done internally with a channel/semaphore.
4 -// So the call `RateLimiter.LimitedGo` may block until another
5 -// child is Closed().
6 -package ratelimit
7 -
8 -import (
9 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
10 -)
11 -
12 -// RateLimiter limits the spawning of children. It does so
13 -// with an internal semaphore. Note that Go will continue
14 -// to be the unlimited process.Process.Go, and ONLY the
15 -// added function `RateLimiter.LimitedGo` will honor the
16 -// limit. This is to improve readability and avoid confusion
17 -// for the reader, particularly if code changes over time.
18 -type RateLimiter struct {
19 - process.Process
20 -
21 - limiter chan struct{}
22 -}
23 -
24 -func NewRateLimiter(parent process.Process, limit int) *RateLimiter {
25 - proc := process.WithParent(parent)
26 - return &RateLimiter{Process: proc, limiter: LimitChan(limit)}
27 -}
28 -
29 -// LimitedGo creates a new process, adds it as a child, and spawns the
30 -// ProcessFunc f in its own goroutine, but may block according to the
31 -// internal rate limit. It is equivalent to:
32 -//
33 -// func(f process.ProcessFunc) {
34 -// <-limitch
35 -// p.Go(func (child process.Process) {
36 -// f(child)
37 -// f.Close() // make sure its children close too!
38 -// limitch<- struct{}{}
39 -// })
40 -/// }
41 -//
42 -// It is useful to construct simple asynchronous workers, children of p,
43 -// and rate limit their creation, to avoid spinning up too many, too fast.
44 -// This is great for providing backpressure to producers.
45 -func (rl *RateLimiter) LimitedGo(f process.ProcessFunc) {
46 -
47 - <-rl.limiter
48 - p := rl.Go(f)
49 -
50 - // this <-closed() is here because the child may have spawned
51 - // children of its own, and our rate limiter should capture that.
52 - go func() {
53 - <-p.Closed()
54 - rl.limiter <- struct{}{}
55 - }()
56 -}
57 -
58 -// LimitChan returns a rate-limiting channel. it is the usual, simple,
59 -// golang-idiomatic rate-limiting semaphore. This function merely
60 -// initializes it with certain buffer size, and sends that many values,
61 -// so it is ready to be used.
62 -func LimitChan(limit int) chan struct{} {
63 - limitch := make(chan struct{}, limit)
64 - for i := 0; i < limit; i++ {
65 - limitch <- struct{}{}
66 - }
67 - return limitch
68 -}
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/ratelimit_test.go deleted
-98
@@ -1,98 +0,0 @@
1 -package ratelimit
2 -
3 -import (
4 - "testing"
5 - "time"
6 -
7 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 -)
9 -
10 -func TestRateLimitLimitedGoBlocks(t *testing.T) {
11 - numChildren := 6
12 -
13 - t.Logf("create a rate limiter with limit of %d", numChildren/2)
14 - rl := NewRateLimiter(process.Background(), numChildren/2)
15 -
16 - doneSpawning := make(chan struct{})
17 - childClosing := make(chan struct{})
18 -
19 - t.Log("spawn 6 children with LimitedGo.")
20 - go func() {
21 - for i := 0; i < numChildren; i++ {
22 - rl.LimitedGo(func(child process.Process) {
23 - // hang until we drain childClosing
24 - childClosing <- struct{}{}
25 - })
26 - t.Logf("spawned %d", i)
27 - }
28 - close(doneSpawning)
29 - }()
30 -
31 - t.Log("should have blocked.")
32 - select {
33 - case <-doneSpawning:
34 - t.Error("did not block")
35 - case <-time.After(time.Millisecond): // for scheduler
36 - t.Log("blocked")
37 - }
38 -
39 - t.Logf("drain %d children so they close", numChildren/2)
40 - for i := 0; i < numChildren/2; i++ {
41 - t.Logf("closing %d", i)
42 - <-childClosing // consume child cloing
43 - t.Logf("closed %d", i)
44 - }
45 -
46 - t.Log("should be done spawning.")
47 - select {
48 - case <-doneSpawning:
49 - case <-time.After(100 * time.Millisecond): // for scheduler
50 - t.Error("still blocked...")
51 - }
52 -
53 - t.Logf("drain %d children so they close", numChildren/2)
54 - for i := 0; i < numChildren/2; i++ {
55 - <-childClosing
56 - t.Logf("closed %d", i)
57 - }
58 -
59 - rl.Close() // ensure everyone's closed.
60 -}
61 -
62 -func TestRateLimitGoDoesntBlock(t *testing.T) {
63 - numChildren := 6
64 -
65 - t.Logf("create a rate limiter with limit of %d", numChildren/2)
66 - rl := NewRateLimiter(process.Background(), numChildren/2)
67 -
68 - doneSpawning := make(chan struct{})
69 - childClosing := make(chan struct{})
70 -
71 - t.Log("spawn 6 children with usual Process.Go.")
72 - go func() {
73 - for i := 0; i < numChildren; i++ {
74 - rl.Go(func(child process.Process) {
75 - // hang until we drain childClosing
76 - childClosing <- struct{}{}
77 - })
78 - t.Logf("spawned %d", i)
79 - }
80 - close(doneSpawning)
81 - }()
82 -
83 - t.Log("should not have blocked.")
84 - select {
85 - case <-doneSpawning:
86 - t.Log("did not block")
87 - case <-time.After(100 * time.Millisecond): // for scheduler
88 - t.Error("process.Go blocked. it should not.")
89 - }
90 -
91 - t.Log("drain children so they close")
92 - for i := 0; i < numChildren; i++ {
93 - <-childClosing
94 - t.Logf("closed %d", i)
95 - }
96 -
97 - rl.Close() // ensure everyone's closed.
98 -}
cmd/ipfswatch/main.go
+1 -1
@@ -7,7 +7,6 @@ import (
7 "os/signal"
8 "path/filepath"
9
10 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
10 homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
11 fsnotify "github.com/ipfs/go-ipfs/Godeps/_workspace/src/gopkg.in/fsnotify.v1"
12 commands "github.com/ipfs/go-ipfs/commands"
@@ -16,6 +15,7 @@ import (
15 coreunix "github.com/ipfs/go-ipfs/core/coreunix"
16 config "github.com/ipfs/go-ipfs/repo/config"
17 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
18 + process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
19 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
20 )
21
core/bootstrap.go
+3 -3
@@ -15,9 +15,9 @@ import (
15 inet "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/net"
16 peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
17
18 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
19 - procctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
20 - periodicproc "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic"
18 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
19 + procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
20 + periodicproc "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/periodic"
21 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
22 )
23
core/builder.go
+1 -1
@@ -7,7 +7,6 @@ import (
7
8 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 dsync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
10 - goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
10 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
11 key "github.com/ipfs/go-ipfs/blocks/key"
12 bserv "github.com/ipfs/go-ipfs/blockservice"
@@ -17,6 +16,7 @@ import (
16 pin "github.com/ipfs/go-ipfs/pin"
17 repo "github.com/ipfs/go-ipfs/repo"
18 cfg "github.com/ipfs/go-ipfs/repo/config"
19 + goprocessctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
20 ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto"
21 peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
22 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
core/core.go
+1 -1
@@ -18,9 +18,9 @@ import (
18
19 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
20 b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
21 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
21 mamask "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter"
22 diag "github.com/ipfs/go-ipfs/diagnostics"
23 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
24 ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr"
25 ic "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto"
26 discovery "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/discovery"
core/corehttp/corehttp.go
+1 -1
@@ -10,8 +10,8 @@ import (
10 "net/http"
11 "time"
12
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
13 core "github.com/ipfs/go-ipfs/core"
14 + "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
15 ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr"
16 manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net"
17 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
exchange/bitswap/bitswap.go
+2 -2
@@ -8,8 +8,6 @@ import (
8 "sync"
9 "time"
10
11 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
12 - procctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
11 blocks "github.com/ipfs/go-ipfs/blocks"
12 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
13 key "github.com/ipfs/go-ipfs/blocks/key"
@@ -20,6 +18,8 @@ import (
18 notifications "github.com/ipfs/go-ipfs/exchange/bitswap/notifications"
19 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
20 "github.com/ipfs/go-ipfs/thirdparty/delay"
21 + process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
22 + procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
23 peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
24 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
25 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
exchange/bitswap/workers.go
+2 -2
@@ -3,8 +3,8 @@ package bitswap
3 import (
4 "time"
5
6 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
7 - procctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
6 + process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
7 + procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
8 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9
10 key "github.com/ipfs/go-ipfs/blocks/key"
fuse/mount/fuse.go
+2 -1
@@ -11,7 +11,8 @@ import (
11
12 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
13 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
14 +
15 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
16 )
17
18 var ErrNotMounted = errors.New("not mounted")
fuse/mount/mount.go
+1 -2
@@ -8,8 +8,7 @@ import (
8 "runtime"
9 "time"
10
11 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
12 -
11 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
12 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
13 )
14
namesys/republisher/repub.go
+2 -2
@@ -15,8 +15,8 @@ import (
15
16 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
17 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
18 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
19 - gpctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
18 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
19 + gpctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
20 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
21 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
22 )
namesys/republisher/repub_test.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "testing"
6 "time"
7
8 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
8 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10
11 "github.com/ipfs/go-ipfs/core"
package.json
+5
@@ -16,6 +16,11 @@
16 "name": "go-net",
17 "hash": "QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt",
18 "version": "0.0.0"
19 + },
20 + {
21 + "name": "goprocess",
22 + "hash": "QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn",
23 + "version": "0.0.0"
24 }
25 ],
26 "language": "go",
routing/dht/dht.go
+2 -2
@@ -22,8 +22,8 @@ import (
22
23 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
24 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
25 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
26 - goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
25 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
26 + goprocessctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
27 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
28 )
29
routing/dht/dht_bootstrap.go
+2 -2
@@ -12,8 +12,8 @@ import (
12 u "github.com/ipfs/go-ipfs/util"
13 peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
14
15 - goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
16 - periodicproc "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic"
15 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
16 + periodicproc "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/periodic"
17 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
18 )
19
routing/dht/providers.go
+2 -2
@@ -3,9 +3,9 @@ package dht
3 import (
4 "time"
5
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
7 - goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 + goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
8 + goprocessctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
9 peer "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer"
10
11 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
routing/dht/query.go
+2 -2
@@ -13,8 +13,8 @@ import (
13 queue "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/peer/queue"
14 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
15
16 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
17 - ctxproc "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
16 + process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
17 + ctxproc "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
18 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
19 )
20
thirdparty/notifier/notifier.go
+2 -2
@@ -6,8 +6,8 @@ package notifier
6 import (
7 "sync"
8
9 - process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
10 - ratelimit "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
9 + process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
10 + ratelimit "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/ratelimit"
11 )
12
13 // Notifiee is a generic interface. Clients implement