merged system layer support

This commit is contained in:
Mikaël Cluseau
2026-04-21 08:41:53 +02:00
parent 1ad9785d07
commit aed66da8b4
4 changed files with 298 additions and 24 deletions

View File

@@ -0,0 +1,28 @@
package main
import "sync"
var (
opMutexes = map[string]*sync.Mutex{}
opsLock sync.Mutex
)
func opMutex[T any](key string, op func() (T, error)) (T, error) {
lock := func() *sync.Mutex {
opsLock.Lock()
defer opsLock.Unlock()
lock, ok := opMutexes[key]
if !ok {
lock = new(sync.Mutex)
opMutexes[key] = lock
}
return lock
}()
lock.Lock()
defer lock.Unlock()
return op()
}