Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
37 lines
913 B
Go
37 lines
913 B
Go
package agentextension
|
|
|
|
import "sync"
|
|
|
|
type runtimeInstallLock struct {
|
|
mu sync.Mutex
|
|
refs int
|
|
}
|
|
|
|
// lockRuntimeInstall prevents the background reconciler and an explicit setup
|
|
// action from replacing the same managed Runtime concurrently. Different
|
|
// Runtime identities may still install in parallel.
|
|
func (s *SetupService) lockRuntimeInstall(key string) func() {
|
|
s.runtimeInstallLocksMu.Lock()
|
|
if s.runtimeInstallLocks == nil {
|
|
s.runtimeInstallLocks = map[string]*runtimeInstallLock{}
|
|
}
|
|
lock := s.runtimeInstallLocks[key]
|
|
if lock == nil {
|
|
lock = &runtimeInstallLock{}
|
|
s.runtimeInstallLocks[key] = lock
|
|
}
|
|
lock.refs++
|
|
s.runtimeInstallLocksMu.Unlock()
|
|
|
|
lock.mu.Lock()
|
|
return func() {
|
|
lock.mu.Unlock()
|
|
s.runtimeInstallLocksMu.Lock()
|
|
lock.refs--
|
|
if lock.refs == 0 && s.runtimeInstallLocks[key] == lock {
|
|
delete(s.runtimeInstallLocks, key)
|
|
}
|
|
s.runtimeInstallLocksMu.Unlock()
|
|
}
|
|
}
|