Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SpinFor = 50
SpinFor controls the number of iterations Lock/Clock is allowed to spin for before resorting to a slower (channel based) way of locking.
Functions ¶
This section is empty.
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is a context-aware mutual exclusion lock. Mutexes can be created as part of other structures; the zero value for a Mutex is an unlocked mutex. See https://golang.org/pkg/sync/#Mutex Supports CLock and TryLock.
func (*Mutex) CLock ¶
CLock tries to lock the mutex. If the mutex is is already locked, the calling goroutine blocks until the mutex is available or the context expires. Returns nil if the lock was taken successfully.
func (*Mutex) Lock ¶
func (m *Mutex) Lock()
Lock the mutex. If the mutex is is already locked, the calling goroutine blocks until the mutex is available.
func (*Mutex) TryLock ¶
TryLock tries to lock the mutex. Does not block. If the mutex is is already locked, returns false immediately. Returns true if the lock was taken successfully.
func (*Mutex) Unlock ¶
func (m *Mutex) Unlock()
Unlock the mutex. Does not block. It is a run-time error (panic) if m is not locked on entry to Unlock.
A locked Mutex is not associated with a particular goroutine. It is allowed for one goroutine to lock a Mutex and then arrange for another goroutine to unlock it.