Class SingleProducerSingleConsumerQueue<TQueueItem>
Special Queue for ZoneTree.
- SingleProducerSingleConsumerQueue is
- thread-safe for single producer and single consumer.
- thread safe for many readers / enumerations
- enquue method uses lock when it is full which makes it almost lock-free for inserts.
- dequeue uses lock but the producer almost never hit the lock.
- Despite this is a FIFO Queue, the enumerator is in LIFO order
to optimize record lookup at TryGetFromReadonlySegments.
Enqueue/Dequeue items in FIFO order: i1,i2,i3,i4
Enumeration in LIFO order: i4,i3,i2,i1
Inheritance
SingleProducerSingleConsumerQueue<TQueueItem>
Assembly: ZoneTree.dll
Syntax
public sealed class SingleProducerSingleConsumerQueue<TQueueItem> : IEnumerable<TQueueItem>, IEnumerable where TQueueItem : class
Type Parameters
Name |
Description |
TQueueItem |
Type of the queue item.
|
Constructors
|
Improve this Doc
View Source
SingleProducerSingleConsumerQueue()
Declaration
public SingleProducerSingleConsumerQueue()
|
Improve this Doc
View Source
SingleProducerSingleConsumerQueue(IEnumerable<TQueueItem>)
Declaration
public SingleProducerSingleConsumerQueue(IEnumerable<TQueueItem> list)
Parameters
Properties
|
Improve this Doc
View Source
IsEmpty
Declaration
public bool IsEmpty { get; }
Property Value
|
Improve this Doc
View Source
Length
Declaration
public int Length { get; }
Property Value
Methods
|
Improve this Doc
View Source
Enqueue(TQueueItem)
Enqueue should not be called more than once at the same time.
Declaration
public void Enqueue(TQueueItem item)
Parameters
Type |
Name |
Description |
TQueueItem |
item |
|
|
Improve this Doc
View Source
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<TQueueItem> GetEnumerator()
Returns
Type |
Description |
IEnumerator<TQueueItem> |
An enumerator that can be used to iterate through the collection.
|
|
Improve this Doc
View Source
ToFirstInFirstArray()
Declaration
public IReadOnlyList<TQueueItem> ToFirstInFirstArray()
Returns
|
Improve this Doc
View Source
ToLastInFirstArray()
Declaration
public IReadOnlyList<TQueueItem> ToLastInFirstArray()
Returns
|
Improve this Doc
View Source
TryDequeue(out TQueueItem)
TryDequeue should not be called more than once at the same time.
Declaration
public bool TryDequeue(out TQueueItem item)
Parameters
Type |
Name |
Description |
TQueueItem |
item |
|
Returns
Implements