MCPcopy Index your code
hub / github.com/foxcpp/maddy / GetContext

Method GetContext

framework/future/future.go:78–105  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

76}
77
78func (f *Future) GetContext(ctx context.Context) (interface{}, error) {
79 if f == nil {
80 panic("nil future used")
81 }
82
83 f.mu.RLock()
84 if f.set {
85 val := f.val
86 err := f.err
87 f.mu.RUnlock()
88 return val, err
89 }
90
91 f.mu.RUnlock()
92 select {
93 case <-f.notify:
94 case <-ctx.Done():
95 return nil, ctx.Err()
96 }
97
98 f.mu.RLock()
99 defer f.mu.RUnlock()
100 if !f.set {
101 panic("future: Notification received, but value is not set")
102 }
103
104 return f.val, f.err
105}

Callers 2

GetMethod · 0.95
TestFuture_WaitCtxFunction · 0.80

Calls 1

ErrMethod · 0.80

Tested by 1

TestFuture_WaitCtxFunction · 0.64