Documentation ¶
Overview ¶
Copyright 2020 Quasisoft Limited - Hong Kong.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityLock ¶
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(ownerProcess int)
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(ownerProcess int)
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
type UnrestrictiveWaitGroup ¶
UnrestrictiveWaitGroup Substitution of sync.WaitGroup that doesn't allow adding more item while the wait has started
func (*UnrestrictiveWaitGroup) Add ¶
func (uwg *UnrestrictiveWaitGroup) Add(additional int64)
func (*UnrestrictiveWaitGroup) Done ¶
func (uwg *UnrestrictiveWaitGroup) Done()
func (*UnrestrictiveWaitGroup) Wait ¶
func (uwg *UnrestrictiveWaitGroup) Wait()