Class SafePriorityQueue
- Namespace
- Sportradar.LiveData.Sdk.Services.PriorityQueue
- Assembly
- Sportradar.LiveData.Sdk.dll
Safe priority queue implementation where element priorities are actually not considered. Under the hood this is actually just a wrapper around .Net FIFO Queue where elements are ordered by time of arrival. This means that PriorityQueueElt comparison operator is not in use here. Queue statistics and Limit events are also disabled here. This is a thread-safe implementation.
public class SafePriorityQueue : ILimitedPriorityQueue, IPriorityQueue
- Inheritance
-
SafePriorityQueue
- Implements
- Inherited Members
Constructors
SafePriorityQueue()
public SafePriorityQueue()
Fields
m_item_sema
Semaphore that is set every time a new item is enqueued
protected SemaphoreSlim m_item_sema
Field Value
m_queue_stats
protected IQueueTimeStats m_queue_stats
Field Value
Properties
Count
Number of items in the queue.
public virtual int Count { get; }
Property Value
Name
Priority queue name
public string Name { get; set; }
Property Value
QueueStats
Queue statistic (total, daily, hourly, minutely). Various avg/min/max performance queue counters.
public IQueueTimeStats QueueStats { get; }
Property Value
Methods
Clear()
Empties the queue.
public void Clear()
Dequeue()
Dequeues an object from the priority queue. Returns null if the queue is empty
public PriorityQueueElt Dequeue()
Returns
- PriorityQueueElt
The top item (max priority) from the queue or null if it does not exist.
Dequeue(Priority)
Dequeues an object of specific priority from the priority queue. Returns null if the queue is empty.
public PriorityQueueElt Dequeue(Priority prio)
Parameters
prioPriorityPriority constraint
Returns
- PriorityQueueElt
The top item (max priority) from the queue or null if it does not exist.
Dequeue(Priority, TimeSpan)
Dequeues an object of specific priority from the priority queue.
public PriorityQueueElt Dequeue(Priority prio, TimeSpan timeout)
Parameters
Returns
- PriorityQueueElt
The top item (max priority) from the queue. Returns null in case of timeout.
Dequeue(TimeSpan)
Dequeues an object from the priority queue.
public PriorityQueueElt Dequeue(TimeSpan timeout)
Parameters
timeoutTimeSpanThe number of milliseconds to wait
Returns
- PriorityQueueElt
The top item (max priority) from the queue. Returns null in case of timeout.
Enqueue(PriorityQueueElt)
Enqueues an item to the priority queue.
public void Enqueue(PriorityQueueElt obj)
Parameters
objPriorityQueueEltThe object to be enqueued.
Peek()
Returns the value of the element at the top of the queue (highest priority) without removing it from the queue. Returns with null immediately if the queue is empty.
public PriorityQueueElt Peek()
Returns
- PriorityQueueElt
The top item (max priority) from the queue or null if it does not exist.
Peek(TimeSpan)
Returns the value of the element at the top of the queue (highest priority) without removing it from the queue.
public PriorityQueueElt Peek(TimeSpan timeout)
Parameters
timeoutTimeSpanThe number of milliseconds to wait
Returns
- PriorityQueueElt
The top item (max priority) from the queue or null if it doesn't exist.
Events
OnLimits
Signals that a queue limit (HIGH, LOW, NORMAL) has been reached or retreated for a specific queue.
public event LimitedPriorityQueueDelegates.QueueLimitDelegate OnLimits