1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
Files
go-mixed/locker/locker.go
2022-05-10 15:08:29 +08:00

22 lines
276 B
Go

package locker
import "sync"
var locks = make(map[string]sync.Locker)
func Lock(name string) {
if l, ok := locks[name]; ok {
l.Lock()
}
new := &sync.Mutex{}
locks[name] = new
new.Lock()
}
func Unlock(name string) {
if l, ok := locks[name]; ok {
l.Unlock()
}
}