完善部分内容
This commit is contained in:
17
pkg/utils/locker.go
Normal file
17
pkg/utils/locker.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user