Documentation
¶
Index ¶
Constants ¶
const ( RWMutexStateUnlocked = iota RWMutexStateExclusive )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RWMutex ¶
type RWMutex struct {
// contains filtered or unexported fields
}
RWMutex is a reader/writer mutual exclusion lock. It wraps the sync package to provide additional capabilities such as lock upgrades & downgrades. It only supports TryLock() & TryRLock() as that is what's supported by our FUSE file system.
func (*RWMutex) State ¶
func (rw *RWMutex) State() RWMutexState
State returns whether the mutex has a exclusive lock, one or more shared locks, or if the mutex is unlocked.
func (*RWMutex) TryLock ¶
func (rw *RWMutex) TryLock() *RWMutexGuard
TryLock tries to lock the mutex for writing and returns a guard if it succeeds.
func (*RWMutex) TryRLock ¶
func (rw *RWMutex) TryRLock() *RWMutexGuard
TryRLock tries to lock rw for reading and reports whether it succeeded.
type RWMutexGuard ¶
type RWMutexGuard struct {
// contains filtered or unexported fields
}
RWMutexGuard is a reference to a held lock.
func (*RWMutexGuard) CanLock ¶
func (g *RWMutexGuard) CanLock() bool
CanLock returns true if the guard can become an exclusive lock.
func (*RWMutexGuard) RLock ¶
func (g *RWMutexGuard) RLock()
RLock downgrades the lock from an exclusive lock to a shared lock. This is a no-op if the lock is already a shared lock.
func (*RWMutexGuard) TryLock ¶
func (g *RWMutexGuard) TryLock() bool
TryLock upgrades the lock from a shared lock to an exclusive lock. This is a no-op if the lock is already an exclusive lock.
func (*RWMutexGuard) Unlock ¶
func (g *RWMutexGuard) Unlock()
Unlock unlocks the underlying mutex. Guard must be discarded after Unlock().
type RWMutexState ¶
type RWMutexState int
RWMutexState represents the lock state of an RWMutexGuard.