MCPcopy Create free account
hub / github.com/devspace-sh/devspace / Context

Method Context

pkg/util/tomb/context.go:35–51  ·  view source on GitHub ↗

Context returns a context that is a copy of the provided parent context with a replaced Done channel that is closed when either the tomb is dying or the parent is cancelled. If parent is nil, it defaults to the parent provided via WithContext, or an empty background parent if the tomb wasn't create

(parent context.Context)

Source from the content-addressed store, hash-verified

33// If parent is nil, it defaults to the parent provided via WithContext, or an
34// empty background parent if the tomb wasn't created via WithContext.
35func (t *Tomb) Context(parent context.Context) context.Context {
36 t.init()
37 t.m.Lock()
38 defer t.m.Unlock()
39
40 if parent == nil {
41 panic("parent context is empty")
42 }
43
44 if child, ok := t.child[parent]; ok {
45 return child.context.(context.Context)
46 }
47
48 child, cancel := context.WithCancel(parent)
49 t.addChild(parent, child, cancel)
50 return child
51}
52
53func (t *Tomb) addChild(parent context.Context, child context.Context, cancel func()) {
54 if t.reason != ErrStillAlive {

Callers 1

startWithRetryMethod · 0.95

Calls 4

initMethod · 0.95
addChildMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected