Documentation ¶
Index ¶
- func Lock(key string)
- func LockFunc(key string, f func())
- func RLock(key string)
- func RLockFunc(key string, f func())
- func RUnlock(key string)
- func Remove(key string)
- func TryLock(key string) bool
- func TryLockFunc(key string, f func()) bool
- func TryRLock(key string) bool
- func TryRLockFunc(key string, f func()) bool
- func Unlock(key string)
- type Locker
- func (that *Locker) Clear()
- func (that *Locker) Lock(key string)
- func (that *Locker) LockFunc(key string, f func())
- func (that *Locker) RLock(key string)
- func (that *Locker) RLockFunc(key string, f func())
- func (that *Locker) RUnlock(key string)
- func (that *Locker) Remove(key string)
- func (that *Locker) TryLock(key string) bool
- func (that *Locker) TryLockFunc(key string, f func()) bool
- func (that *Locker) TryRLock(key string) bool
- func (that *Locker) TryRLockFunc(key string, f func()) bool
- func (that *Locker) Unlock(key string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TryLockFunc ¶
TryLockFunc 尝试对key加锁,如果加锁成功则执行方法f,执行成功返回true,执行失败返回false
func TryRLockFunc ¶
TryRLockFunc 尝试对key加读锁,如果加锁成功则执行方法f,执行成功返回true,加锁失败或执行失败都返回false
Types ¶
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker 内存锁,底层使用map实现
func (*Locker) TryLockFunc ¶
TryLockFunc 尝试对指定的key加锁,加锁成功则执行f方法,如果加锁并执行成功则返回true,否则返回false
func (*Locker) TryRLockFunc ¶
TryRLockFunc 尝试对指定的key加读锁,加锁成功则执行方法f,执行成功返回true,否则返回false
Click to show internal directories.
Click to hide internal directories.