Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MutexGenerator func(path []string) sync.Locker = func(path []string) sync.Locker { return new(sync.Mutex) }
Global function supporting custom Mutex/WaitGroup generators. For example, allowing global treeLocks by handling locks through a database. Or alternatively, enabling callbacks when locking/unlocking occurs
Functions ¶
This section is empty.
Types ¶
type SimpleTreeLock ¶
type SimpleTreeLock struct {
// contains filtered or unexported fields
}
func NewSimpleTreeLock ¶
func NewSimpleTreeLock() *SimpleTreeLock
Equivalent to a TreeLock restricted to depth=1
func (*SimpleTreeLock) Lock ¶
func (T *SimpleTreeLock) Lock(val string)
func (*SimpleTreeLock) LockAll ¶
func (T *SimpleTreeLock) LockAll()
func (*SimpleTreeLock) LockMany ¶
func (T *SimpleTreeLock) LockMany(vals ...string)
func (*SimpleTreeLock) Unlock ¶
func (T *SimpleTreeLock) Unlock(val string)
func (SimpleTreeLock) UnlockAll ¶
func (T SimpleTreeLock) UnlockAll()
func (*SimpleTreeLock) UnlockMany ¶
func (T *SimpleTreeLock) UnlockMany(vals ...string)
type TreeLock ¶
type TreeLock struct {
// contains filtered or unexported fields
}
func (*TreeLock) LockAll ¶
func (T *TreeLock) LockAll()
Lock the entire tree, waits for all existing locks to unlock first.
func (*TreeLock) LockMany ¶
Safely lock multiple values simultaneously while preventing race condition Use this if the same thread will need to have multiple values locked Attempting to lock overlapping values will deadlock
func (*TreeLock) Unlock ¶
Unlock a value to allow it to be used by another thread. Will panic if the value is not locked
func (*TreeLock) UnlockMany ¶
Safely unlock multiple values simultaneously while preventing race condition