1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2024-05-28 04:17:26 +08:00
parent 822932fe15
commit 1abde30d8f
4 changed files with 12 additions and 30 deletions

View File

@ -2,14 +2,16 @@ package locker
import "sync"
type Locker interface {
type locker interface {
Lock()
Unlock()
TryLock() bool
}
type RWLocker interface {
Locker
type rwLocker interface {
Lock()
Unlock()
TryLock() bool
RLock()
RUnlock()
TryRLock() bool
@ -18,3 +20,7 @@ type RWLocker interface {
func NewLocker() *sync.Mutex {
return &sync.Mutex{}
}
func NewRWLocker() *sync.RWMutex {
return &sync.RWMutex{}
}