MCPcopy Create free account
hub / github.com/Shopify/goose / Wait

Method Wait

statetracker/tracker.go:96–116  ·  view source on GitHub ↗

Wait until underlying state is the desired one, returning whether it had to wait or not.

(ctx context.Context, desired interface{})

Source from the content-addressed store, hash-verified

94
95// Wait until underlying state is the desired one, returning whether it had to wait or not.
96func (t *stateTracker) Wait(ctx context.Context, desired interface{}) bool {
97 t.cond.L.Lock()
98 defer t.cond.L.Unlock()
99
100 waited := false
101
102 if t.value != desired {
103 waited = true
104 log(ctx, nil).
105 WithField("current", t.value).
106 WithField("desired", desired).
107 Info("waiting for a state change")
108 }
109
110 // Can be broadcasted many times, wait for the right desired
111 for t.value != desired {
112 t.cond.Wait()
113 }
114
115 return waited
116}
117
118func (t *stateTracker) NewListener() <-chan *Notification {
119 t.cond.L.Lock()

Callers

nothing calls this directly

Calls 1

WaitMethod · 0.65

Tested by

no test coverage detected