Documentation
¶
Index ¶
- type Mutex
- func (that *Mutex) IsLocked() bool
- func (that *Mutex) IsRLocked() bool
- func (that *Mutex) IsWLocked() bool
- func (that *Mutex) Lock()
- func (that *Mutex) LockFunc(f func())
- func (that *Mutex) RLock()
- func (that *Mutex) RLockFunc(f func())
- func (that *Mutex) RUnlock()
- func (that *Mutex) TryLock() bool
- func (that *Mutex) TryLockFunc(f func()) (result bool)
- func (that *Mutex) TryRLock() bool
- func (that *Mutex) TryRLockFunc(f func()) (result bool)
- func (that *Mutex) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex 高级互斥锁 使用atomic + channel实现的高级互斥锁模块,支持更丰富的互斥锁特性 互斥锁对象支持读写控制,互斥锁功能逻辑与标准库sync.RWMutex类似,可并发读但不可并发写
func (*Mutex) LockFunc ¶
func (that *Mutex) LockFunc(f func())
LockFunc 使用写锁执行一段代码,不用担心panic,因为使用defer解锁,所以无论如何都会解锁成功
func (*Mutex) TryLockFunc ¶
TryLockFunc 尝试加锁并执行方法,加锁成功则会执行方法,加锁失败什么都不做, 返回值result表示加锁是否成功
func (*Mutex) TryRLockFunc ¶
TryRLockFunc 尝试加读锁执行一段方法,加锁成功则会执行,加锁失败则什么都不做,返回值result表示加锁是否成功
Click to show internal directories.
Click to hide internal directories.