MCPcopy Create free account
hub / github.com/diillson/chatcli / WithLock

Method WithLock

cli/agent/workers/file_lock.go:52–57  ·  view source on GitHub ↗

WithLock runs fn while holding the lock for path. The lock is always released, even if fn panics.

(path string, fn func() error)

Source from the content-addressed store, hash-verified

50// WithLock runs fn while holding the lock for path.
51// The lock is always released, even if fn panics.
52func (m *FileLockManager) WithLock(path string, fn func() error) error {
53 lock := m.getLock(path)
54 lock.Lock()
55 defer lock.Unlock()
56 return fn()
57}

Callers 1

Calls 3

getLockMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by 1