Search Results for

    Show / Hide Table of Contents

    Class SingleProducerSingleConsumerQueue<TQueueItem>

    Special Queue for ZoneTree.

    1. SingleProducerSingleConsumerQueue is
    • thread-safe for single producer and single consumer.
    • thread safe for many readers / enumerations
    1. enquue method uses lock when it is full which makes it almost lock-free for inserts.
    2. dequeue uses lock but the producer almost never hit the lock.
    3. 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
    object
    SingleProducerSingleConsumerQueue<TQueueItem>
    Implements
    IEnumerable<TQueueItem>
    IEnumerable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Tenray.ZoneTree.Collections
    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
    Type Name Description
    IEnumerable<TQueueItem> list

    Properties

    | Improve this Doc View Source

    IsEmpty

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool
    | Improve this Doc View Source

    Length

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    int

    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
    Type Description
    IReadOnlyList<TQueueItem>
    | Improve this Doc View Source

    ToLastInFirstArray()

    Declaration
    public IReadOnlyList<TQueueItem> ToLastInFirstArray()
    Returns
    Type Description
    IReadOnlyList<TQueueItem>
    | 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
    Type Description
    bool

    Implements

    IEnumerable<T>
    IEnumerable
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2022 Tenray.io