Documentation ¶
Overview ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryReverse ¶
func InitLogging ¶
Types ¶
type Hasher ¶
Hahsher is thread-safe. If you see contention on the mutex, you may want to consider a sync.Map. Since we only write to the map once per key, and read from it many times, it might make sense.
type PriorityLock ¶
type PriorityLock interface { Lock() Unlock() HighPriorityLock() HighPriorityUnlock() }
type PriorityPreferenceLock ¶
type PriorityPreferenceLock struct {
// contains filtered or unexported fields
}
PriorityPreferenceLock implements a simple triple-mutex priority lock patterns are like:
Low Priority would do: lock lowPriorityMutex, wait for high priority groups, lock nextToAccess, lock dataMutex, unlock nextToAccess, do stuff, unlock dataMutex, unlock lowPriorityMutex High Priority would do: increment high priority waiting, lock nextToAccess, lock dataMutex, unlock nextToAccess, do stuff, unlock dataMutex, decrement high priority waiting
func NewPriorityPreferenceLock ¶
func NewPriorityPreferenceLock() *PriorityPreferenceLock
func (*PriorityPreferenceLock) HighPriorityLock ¶
func (lock *PriorityPreferenceLock) HighPriorityLock()
HighPriorityLock will acquire a high-priority lock it must still wait until a low-priority lock has been released and then potentially other high priority lock contenders.
func (*PriorityPreferenceLock) HighPriorityUnlock ¶
func (lock *PriorityPreferenceLock) HighPriorityUnlock()
HighPriorityUnlock will unlock the high-priority lock
func (*PriorityPreferenceLock) Lock ¶
func (lock *PriorityPreferenceLock) Lock()
Lock will acquire a low-priority lock it must wait until both low priority and all high priority lock holders are released.
func (*PriorityPreferenceLock) Unlock ¶
func (lock *PriorityPreferenceLock) Unlock()
Unlock will unlock the low-priority lock