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

Method TryLock

locking/local_locker.go:46–58  ·  view source on GitHub ↗
(key, identifier string)

Source from the content-addressed store, hash-verified

44var _ Locker = &keyMutex{}
45
46func (k *keyMutex) TryLock(key, identifier string) bool {
47 mux, _ := k.muxes.LoadOrStore(key, &lockWithIdent{
48 mux: sync.Mutex{},
49 })
50 keyMux := mux.(*lockWithIdent)
51 locked := keyMux.mux.TryLock()
52 if locked {
53 keyMux.ident = identifier
54 keyMux.isLocked.Store(true)
55 }
56
57 return locked
58}
59
60func (k *keyMutex) Lock(key, identifier string) {
61 mux, _ := k.muxes.LoadOrStore(key, &lockWithIdent{

Callers 1

LockWithContextMethod · 0.95

Calls 1

TryLockMethod · 0.65

Tested by

no test coverage detected