docs.unity3d.com
    Show / Hide Table of Contents

    Struct OwnedAtomicQueue<T>

    A generic, multiple-reader, multiple-writer concurrent queue. The queue uses a sentinel node to track each end of the queue. When the queue is empty, the first and last nodes point to each other. Elements are added to the queue between the last and next-to-last nodes, whose pointers are updated accordingly. The element removed from the queue is always the next-to-first, and the pointers of the first and next-to-next-to-first elements are updated.

    Namespace: Unity.Media.Utilities
    Syntax
    public struct OwnedAtomicQueue<T> : IDisposable, IValidatable, IEquatable<OwnedAtomicQueue<T>> where T : struct
    Type Parameters
    Name Description
    T

    The element type

    Remarks

    The difference between this and AtomicQueue<T> is that this manages the payload storage for you and AtomicQueue<T> does not.

    Properties

    IsEmpty

    Whether the queue is empty

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    Due to the concurrent nature of the queue, users should be careful about using this property for decision making

    Valid

    Whether this queue is valid

    Declaration
    public bool Valid { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IValidatable.Valid

    Methods

    AcquirePayloadStorage(out T*)

    Allocates storage for a payload

    Declaration
    public bool AcquirePayloadStorage(out T*payload)
    Parameters
    Type Name Description
    T* payload

    The allocated payload storage will be placed here

    Returns
    Type Description
    Boolean

    True if a previous storage allocation was reused, otherwise false

    Create(AllocationMode)

    Create an OwnedAtomicQueue<T>

    Declaration
    public static OwnedAtomicQueue<T> Create(AllocationMode allocationMode = AllocationMode.Pooled)
    Parameters
    Type Name Description
    AllocationMode allocationMode

    Use the specified allocation mode for the queue's internal free list

    Returns
    Type Description
    OwnedAtomicQueue<T>
    Remarks

    This is the only valid way to create an OwnedAtomicQueue<T>

    Dequeue()

    Remove an element from the queue

    Declaration
    public T Dequeue()
    Returns
    Type Description
    T

    A pointer to the next element from the queue

    Dispose()

    Dispose all resources belonging to the queue

    Declaration
    public void Dispose()

    Enqueue(ref T)

    Add an element to the queue

    Declaration
    public void Enqueue(ref T payload)
    Parameters
    Type Name Description
    T payload

    The element to be added

    Equals(Object)

    Whether this is the same queue as another instance

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The other instance to compare

    Returns
    Type Description
    Boolean

    Equals(OwnedAtomicQueue<T>)

    Whether this is the same queue as another instance

    Declaration
    public bool Equals(OwnedAtomicQueue<T> other)
    Parameters
    Type Name Description
    OwnedAtomicQueue<T> other

    The other instance to compare

    Returns
    Type Description
    Boolean

    GetHashCode()

    Return a unique hash for this queue

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    Peek()

    Returns the next element from the queue without removing it

    Declaration
    public T Peek()
    Returns
    Type Description
    T

    A pointer to the next element from the queue

    ReleasePayloadStorage(T*)

    Releases storage for a payload previously allocated via AcquirePayloadStorage

    Declaration
    public void ReleasePayloadStorage(T*payload)
    Parameters
    Type Name Description
    T* payload

    The payload to release

    TryDequeue(out T)

    Try to remove an element from the queue.

    Declaration
    public bool TryDequeue(out T result)
    Parameters
    Type Name Description
    T result

    If there's an element available, this parameter will be updated to that element.

    Returns
    Type Description
    Boolean

    Whether the dequeueing operation succeeded.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023