Struct NativeQueue<T> | Collections | 0.6.0-preview.9
docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeQueue<T>

    An unmanaged queue.

    Namespace: Unity.Collections
    Syntax
    public struct NativeQueue<T> : IDisposable where T : struct
    Type Parameters
    Name Description
    T

    The type of the elements in the container.

    Constructors

    NativeQueue(Allocator)

    Constructs a new queue with type of memory allocation.

    Declaration
    public NativeQueue(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Properties

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    IsCreated

    Reports whether memory for the container is allocated.

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

    True if this container object's internal storage has been allocated.

    Remarks

    Note that the container storage is not created if you use the default constructor. You must specify at least an allocation type to construct a usable container.

    MemoryBlockSize

    Declaration
    public static int MemoryBlockSize { get; }
    Property Value
    Type Description
    Int32

    PersistentMemoryBlockCount

    Declaration
    public static int PersistentMemoryBlockCount { get; set; }
    Property Value
    Type Description
    Int32

    Methods

    AsParallelWriter()

    Returns parallel reader instance.

    Declaration
    public NativeQueue<T>.ParallelWriter AsParallelWriter()
    Returns
    Type Description
    NativeQueue.ParallelWriter<>

    Clear()

    Clears the container.

    Declaration
    public void Clear()

    Dequeue()

    Dequeue item from the container.

    Declaration
    public T Dequeue()
    Returns
    Type Description
    T

    Returns item from the container.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if queue is empty Count.

    Dispose()

    Disposes of this container and deallocates its memory immediately.

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Safely disposes of this container and deallocates its memory when the jobs that use it have completed.

    Declaration
    public JobHandle Dispose(JobHandle inputDeps)
    Parameters
    Type Name Description
    JobHandle inputDeps

    The job handle or handles for any scheduled jobs that use this container.

    Returns
    Type Description
    JobHandle

    A new job handle containing the prior handles as well as the handle for the job that deletes the container.

    Remarks

    You can call this function dispose of the container immediately after scheduling the job. Pass the JobHandle returned by the Job.Schedule method using the jobHandle parameter so the job scheduler can dispose the container after all jobs using it have run.

    Enqueue(T)

    Enqueue value into the container.

    Declaration
    public void Enqueue(T value)
    Parameters
    Type Name Description
    T value

    The value to be appended.

    Peek()

    Declaration
    public T Peek()
    Returns
    Type Description
    T

    TryDequeue(out T)

    Try dequeueing item from the container. If container is empty item won't be changed, and return result will be false.

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

    Item value if dequeued.

    Returns
    Type Description
    Boolean

    Returns true if item was dequeued.

    Extension Methods

    JobNativeMultiHashMapVisitKeyValue.Schedule<TJob, TKey, TValue>(TJob, NativeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobNativeMultiHashMapVisitKeyMutableValue.Schedule<TJob, TKey, TValue>(TJob, NativeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobUnsafeMultiHashMapVisitKeyValue.Schedule<TJob, TKey, TValue>(TJob, UnsafeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobUnsafeMultiHashMapVisitKeyMutableValue.Schedule<TJob, TKey, TValue>(TJob, UnsafeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    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