Class BaseOrderedBlockingQueue<TSort, TValue, TCollection>
- Namespace
- Ecng.Collections
- Assembly
- Ecng.Collections.dll
Represents a base class for an ordered blocking queue that sorts elements based on a specified key.
public abstract class BaseOrderedBlockingQueue<TSort, TValue, TCollection> : BaseBlockingQueue<(TSort sort, TValue elem), TCollection>, ISynchronizedCollection<(TSort sort, TValue elem)>, ISynchronizedCollection, ICollection<(TSort sort, TValue elem)>, IEnumerable<(TSort sort, TValue elem)>, IEnumerable, IBlockingQueue<(TSort sort, TValue elem)> where TCollection : ICollection<(TSort, TValue)>, IQueue<(TSort, TValue)>
Type Parameters
TSort
The type used to determine the sort order of elements.
TValue
The type of the values stored in the queue.
TCollection
The type of the inner collection, which must implement ICollection<T> and IQueue<T> for tuples of
TSort
andTValue
.
- Inheritance
-
BaseOrderedBlockingQueue<TSort, TValue, TCollection>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
BaseOrderedBlockingQueue(TCollection)
Represents a base class for an ordered blocking queue that sorts elements based on a specified key.
protected BaseOrderedBlockingQueue(TCollection collection)
Parameters
collection
TCollection
Methods
Enqueue(TSort, TValue)
Adds a new value to the queue with the specified sort order.
protected void Enqueue(TSort sort, TValue value)
Parameters
sort
TSortThe sort key determining the order of the value in the queue.
value
TValueThe value to add to the queue.
OnDequeue()
Removes and returns the next item from the inner collection.
protected override (TSort, TValue) OnDequeue()
Returns
- (TSort, TValue)
The tuple containing the sort key and value of the dequeued item.
OnEnqueue((TSort, TValue), bool)
Adds an item to the inner collection when enqueuing.
protected override void OnEnqueue((TSort, TValue) item, bool force)
Parameters
item
(TSort, TValue)The tuple containing the sort key and value to enqueue.
force
boolIf true, forces the item to be enqueued even if the queue is full; otherwise, respects the maximum size limit.
OnPeek()
Retrieves, but does not remove, the next item from the inner collection.
protected override (TSort, TValue) OnPeek()
Returns
- (TSort, TValue)
The tuple containing the sort key and value of the item at the head of the queue.
TryDequeue(out TValue, bool, bool)
Attempts to remove and return the next value from the queue.
public bool TryDequeue(out TValue value, bool exitOnClose = true, bool block = true)
Parameters
value
TValueWhen this method returns, contains the dequeued value if successful; otherwise, the default value of
TValue
.exitOnClose
boolIf true, exits immediately if the queue is closed; otherwise, waits for an item.
block
boolIf true, blocks until an item is available; otherwise, returns immediately.
Returns
- bool
True if a value was successfully dequeued; otherwise, false.