Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Locker ¶
type Locker interface { // Lock try locking object, return err if fails. Lock() error // Unlock unlock object lock, if fail return err Unlock() error // TryLock will try to lock object and return whether it succeed or not without blocking. TryLock() bool }
func NewFileLock ¶
NewFileLock create new file lock instance
func NewMemoryLock ¶
NewMemoryLock create new memory lock instance
type MemoryLock ¶
type MemoryLock struct {
// contains filtered or unexported fields
}
MemoryLock implements sync/Locker, default 0 indicates an unlocked memory.
func (*MemoryLock) Lock ¶
func (sl *MemoryLock) Lock() error
Lock locks memory. If the lock is locked before, the caller will be blocked until unlocked.
func (*MemoryLock) TryLock ¶
func (sl *MemoryLock) TryLock() bool
TryLock will try to lock memory and return whether it succeed or not without blocking.
func (*MemoryLock) Unlock ¶
func (sl *MemoryLock) Unlock() error
Unlock unlocks memory, this operation is reentrant。
Click to show internal directories.
Click to hide internal directories.