Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lockable ¶
type Lockable interface { Lock() Unlock() }
Lockable defines minimal interface for types that are supported
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker is a struct used for locking/unlocking It's possible to implement with free functions but the code will become more complex. Feel free to make a PR if you need such functionality
func (*Locker) Lock ¶
Lock is a function that locks all resources provided. It's guaranteed to avoid deadlock for TryLockable types but might potentially fail into livelock. It has high chance of avoiding deadlock on regular locks as well, but deadlock avoidance is not guaranteed. If a panic is thrown during locking of one of the resouces it'll unlock all the acquired resources.
func (*Locker) TryLock ¶
func (l *Locker) TryLock(locks ...TryLockable) bool
TryLock tries to acquire all provided resources. If a panic is thrown during locking of one of the resouces it'll unlock all the acquired resources.
type TryLockable ¶
TryLockable extended Lockable interface that allows better functionality