1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2026-07-27 17:56:31 +08:00
This commit is contained in:
2022-05-26 14:12:42 +08:00
parent a5cc6eb04c
commit a31e054a70
3 changed files with 6 additions and 18 deletions
+1 -4
View File
@@ -1,9 +1,6 @@
package locker package locker
// 空锁 var EmptyLocker = &emptyLocker{}
var _ Locker = &emptyLocker{}
var _ RWLocker = &emptyLocker{}
type emptyLocker struct{} type emptyLocker struct{}
+2 -7
View File
@@ -15,11 +15,6 @@ type RWLocker interface {
TryRLock() bool TryRLock() bool
} }
type locker struct { func NewLocker() *sync.Mutex {
*sync.Mutex return &sync.Mutex{}
} }
func NewLocker() *locker {
return &locker{Mutex: &sync.Mutex{}}
}
+3 -7
View File
@@ -2,12 +2,8 @@ package locker
import "sync" import "sync"
var _ RWLocker = &rwLocker{} var _ RWLocker = &sync.RWMutex{}
type rwLocker struct { func NewRWLocker() *sync.RWMutex {
*sync.RWMutex return &sync.RWMutex{}
}
func NewRWLocker() *rwLocker {
return &rwLocker{RWMutex: &sync.RWMutex{}}
} }