mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
26 lines
271 B
Go
26 lines
271 B
Go
package locker
|
|
|
|
import "sync"
|
|
|
|
type Locker interface {
|
|
Lock()
|
|
Unlock()
|
|
TryLock() bool
|
|
}
|
|
|
|
type RWLocker interface {
|
|
Locker
|
|
RLock()
|
|
RUnlock()
|
|
TryRLock() bool
|
|
}
|
|
|
|
type locker struct {
|
|
*sync.Mutex
|
|
}
|
|
|
|
func NewLocker() *locker {
|
|
return &locker{Mutex: &sync.Mutex{}}
|
|
}
|
|
|