Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Priority ¶
type Priority int16
func DefaultPriorities ¶ added in v0.2.0
func DefaultPriorities() []Priority
type PriorityLock ¶
type PriorityLock struct {
// contains filtered or unexported fields
}
PriorityLock holds information about state of current lock. All goroutines operating on common resource should also use common PriorityLock instance.
func NewPriorityLock ¶
func NewPriorityLock(priorityPool []Priority) *PriorityLock
NewPriorityLock creates fresh instance with no active locks.
func NewPriorityLockWithDefaultPriorities ¶ added in v0.2.0
func NewPriorityLockWithDefaultPriorities() *PriorityLock
NewPriorityLockWithDefaultPriorities creates fresh instance with no active locks using DefaultPriorities functions as source of definition for priorities.
func (*PriorityLock) Lock ¶
func (l *PriorityLock) Lock(priority Priority)
Lock will try to acquire lock for current goroutine (or other resource owner). Priority acts as importance level for given goroutine process. If Priority is highest from all acquired locks it means current goroutine will be next to obtain the lock regardless of the order of Lock method invocation. For duplicated Priority values the order of Lock method invocation will determinate next lock owner.
func (*PriorityLock) Unlock ¶
func (l *PriorityLock) Unlock()
Unlock will release lock held by goroutine (or other resource owner). It will remove the highest Priority value from PriorityLock pool and using sync.Cond it will signal all locks to check which goroutine can go next.