mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-18 22:10:09 +08:00

- Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local)
20 lines
399 B
Go
20 lines
399 B
Go
package waitable
|
|
|
|
import (
|
|
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
|
)
|
|
|
|
type Waitable interface {
|
|
Closing() <-chan struct{}
|
|
}
|
|
|
|
// Context returns a context that cancels when the waitable is closing.
|
|
func Context(w Waitable) context.Context {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
go func() {
|
|
<-w.Closing()
|
|
cancel()
|
|
}()
|
|
return ctx
|
|
}
|