Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KRWMutex ¶
type KRWMutex struct {
// contains filtered or unexported fields
}
func NewKRWMutex ¶
func NewKRWMutex() *KRWMutex
type LockableEntity ¶
type LockableEntity interface {
// Locks returns the locks that the entity needs to lock.
Locks() (locks []interface{})
}
LockableEntity is an interface that allows to lock (and unlock) entities that are generating complex locks.
type MultiMutex ¶
type MultiMutex struct {
// contains filtered or unexported fields
}
MultiMutex is a mutex that allows to lock multiple entities exclusively. Entities are represented by interface{} identifiers and can be presented in arbitrary order. Goroutine 1 Goroutine 2 Goroutine 3
Lock(a,c) - Lock(c,b) <- blocking work Lock(b) wait
Unlock(a,c) work wait
- Unlock(b) wait
- - Lock(c,b) <- successful
func (*MultiMutex) Lock ¶
func (m *MultiMutex) Lock(ids ...interface{})
Lock blocks until all locks given by ids can be acquired atomically.
func (*MultiMutex) LockEntity ¶
func (m *MultiMutex) LockEntity(entity LockableEntity)
LockEntity locks all locks that are required for the given LockableEntity.
func (*MultiMutex) Unlock ¶
func (m *MultiMutex) Unlock(ids ...interface{})
Unlock releases the locks of ids.
func (*MultiMutex) UnlockEntity ¶
func (m *MultiMutex) UnlockEntity(entity LockableEntity)
UnlockEntity unlocks all locks that are required for the given LockableEntity.
type MultiMutexLockBuilder ¶
type MultiMutexLockBuilder struct {
// contains filtered or unexported fields
}
func (*MultiMutexLockBuilder) AddLock ¶
func (lockBuilder *MultiMutexLockBuilder) AddLock(identifier interface{}) *MultiMutexLockBuilder
func (*MultiMutexLockBuilder) Build ¶
func (lockBuilder *MultiMutexLockBuilder) Build() []interface{}
type RWMultiMutex ¶
type RWMultiMutex struct {
// contains filtered or unexported fields
}
func (*RWMultiMutex) Lock ¶
func (mutex *RWMultiMutex) Lock(identifiers ...interface{})
func (*RWMultiMutex) RLock ¶
func (mutex *RWMultiMutex) RLock(identifiers ...interface{})
func (*RWMultiMutex) RUnlock ¶
func (mutex *RWMultiMutex) RUnlock(identifiers ...interface{})
func (*RWMultiMutex) Unlock ¶
func (mutex *RWMultiMutex) Unlock(identifiers ...interface{})