mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 08:32:40 +08:00
locker
This commit is contained in:
@ -6,10 +6,17 @@ type ChanLocker interface {
|
||||
}
|
||||
|
||||
type chanSourceLock struct {
|
||||
m RWLocker
|
||||
m rwLocker
|
||||
content map[string]chan int
|
||||
}
|
||||
|
||||
func NewChanSourceLocker() *chanSourceLock {
|
||||
return &chanSourceLock{
|
||||
m: NewRWLocker(),
|
||||
content: make(map[string]chan int),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *chanSourceLock) Get(key string) (ch <-chan int, ok bool) {
|
||||
s.m.RLock()
|
||||
ch, ok = s.content[key]
|
||||
|
Reference in New Issue
Block a user