MCPcopy Create free account
hub / github.com/cloudbase/garm / LockWithContext

Method LockWithContext

locking/local_locker.go:70–84  ·  view source on GitHub ↗
(ctx context.Context, key, identifier string)

Source from the content-addressed store, hash-verified

68}
69
70func (k *keyMutex) LockWithContext(ctx context.Context, key, identifier string) error {
71 ticker := time.NewTicker(time.Second)
72 defer ticker.Stop()
73
74 for {
75 if k.TryLock(key, identifier) {
76 return nil
77 }
78 select {
79 case <-ctx.Done():
80 return ctx.Err()
81 case <-ticker.C:
82 }
83 }
84}
85
86func (k *keyMutex) Unlock(key string, remove bool) {
87 mux, ok := k.muxes.Load(key)

Callers

nothing calls this directly

Calls 3

TryLockMethod · 0.95
StopMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected