ThreadSafePriorityQueueWithUpdate
Engine/source/platform/threads/threadSafePriorityQueue.h
Fast, lock-free priority queue implementation for concurrent access that performs dynamic re-prioritization of items.
Protected Types
NodePtr
ThreadSafePriorityQueue< T, K, SORT_MIN_TO_MAX, MAX_LEVEL, PROBABILISTIC_BIAS >
Parent
TickType
Protected Attributes
If this is non-zero, priorities will be boosted by this amount each update. This can be used to prevent constant high-priority inserts to starve low-priority items already in the queue.
ThreadSafePriorityQueue< NodePtr, TickType, true, MAX_LEVEL, PROBABILISTIC_BIAS >
Work queue for node updates.
Public Functions
ThreadSafePriorityQueueWithUpdate(U32 updateInterval)
Return the delta to apply to priorities on each update.
Return the current update interval in milliseconds.
setTimeBasedPriorityBoost(KeyType value)
Set the delta for time-based priority adjustments to the given value.
setUpdateInterval(U32 value)
Set update interval of queue to given value.
Detailed Description
Fast, lock-free priority queue implementation for concurrent access that performs dynamic re-prioritization of items.
Within the bounds of a set update interval UPDATE_INTERVAL, the takeNext method is guaranteed to always return the item that has the highest priority at the time the method is called rather than at the time items were inserted into the queue.
Values placed on the queue must implement the following interface:
template< typename K > struct IThreadSafePriorityQueueItem { // Default constructor. IThreadSafePriorityQueueItem(); // Return the current priority. // This must run normally even if the item is already dead. K getPriority(); // Return true if the item is still meant to be waiting in the queue. bool isAlive(); };
Public Types
@142
Enumerator
- DEFAULT_UPDATE_INTERVAL = 256
typedef K KeyType
typedef T ValueType
Protected Types
typedef Parent::NodePtr NodePtr
typedef ThreadSafePriorityQueue< T, K, SORT_MIN_TO_MAX, MAX_LEVEL, PROBABILISTIC_BIAS > Parent
typedef U32 TickType
Protected Attributes
KeyType mPriorityBoost
If this is non-zero, priorities will be boosted by this amount each update. This can be used to prevent constant high-priority inserts to starve low-priority items already in the queue.
U32 mUpdateInterval
ThreadSafePriorityQueue< NodePtr, TickType, true, MAX_LEVEL, PROBABILISTIC_BIAS > mUpdateQueue
Work queue for node updates.
Public Functions
ThreadSafePriorityQueueWithUpdate(U32 updateInterval)
getTimeBasedPriorityBoost()
Return the delta to apply to priorities on each update.
Set to zero to deactivate time-based priority adjustments.
getUpdateInterval()
Return the current update interval in milliseconds.
insert(KeyType priority, const T & value)
setTimeBasedPriorityBoost(KeyType value)
Set the delta for time-based priority adjustments to the given value.
Call this method on the main thread only.
Parameters:
value | The new priority adjustment value. |
setUpdateInterval(U32 value)
Set update interval of queue to given value.
Call this method on the main thread only.
Parameters:
value | Time between priority updates in milliseconds. |
takeNext(T & outValue, KeyType upToPriority)
updatePriorities()