完善部分内容

This commit is contained in:
dragon
2025-01-06 17:31:18 +08:00
parent 246bf13a6c
commit bb8966521c
5 changed files with 117 additions and 47 deletions

17
pkg/utils/locker.go Normal file
View File

@@ -0,0 +1,17 @@
package utils
import "sync"
type Locker struct {
sy sync.Map
}
func NewLocker() *Locker {
return &Locker{
sy: sync.Map{},
}
}
func (l *Locker) Open(key string) *sync.Mutex {
actual, _ := l.sy.LoadOrStore(key, &sync.Mutex{})
return actual.(*sync.Mutex)
}