Table of Contents

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

SemaphoreSlim

m_queue_stats

protected IQueueTimeStats m_queue_stats

Field Value

IQueueTimeStats

Properties

Count

Number of items in the queue.

public virtual int Count { get; }

Property Value

int

Name

Priority queue name

public string Name { get; set; }

Property Value

string

QueueStats

Queue statistic (total, daily, hourly, minutely). Various avg/min/max performance queue counters.

public IQueueTimeStats QueueStats { get; }

Property Value

IQueueTimeStats

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

prio Priority

Priority 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

prio Priority

Priority constraint

timeout TimeSpan

The number of milliseconds to wait

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

timeout TimeSpan

The 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

obj PriorityQueueElt

The 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

timeout TimeSpan

The 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

Event Type

LimitedPriorityQueueDelegates.QueueLimitDelegate