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

Function TryLock

locking/locking.go:29–40  ·  view source on GitHub ↗
(key, identifier string)

Source from the content-addressed store, hash-verified

27var lockerMux = sync.Mutex{}
28
29func TryLock(key, identifier string) (ok bool) {
30 if locker == nil {
31 panic("no locker is registered")
32 }
33
34 _, filename, line, _ := runtime.Caller(1)
35 slog.Debug("attempting to try lock", "key", key, "identifier", identifier, "caller", fmt.Sprintf("%s:%d", filename, line))
36 defer slog.Debug("try lock returned", "key", key, "identifier", identifier, "locked", ok, "caller", fmt.Sprintf("%s:%d", filename, line))
37
38 ok = locker.TryLock(key, identifier)
39 return ok
40}
41
42func Lock(key, identifier string) {
43 if locker == nil {

Calls 1

TryLockMethod · 0.65

Tested by 2

TestTryLockMethod · 0.68