Struct UnsafeRingQueue<T>
Fixed-size circular buffer, without any thread safety check features.
Namespace: Unity.Collections.LowLevel.Unsafe
Syntax
public struct UnsafeRingQueue<T> : INativeDisposable, IDisposable where T : struct
Type Parameters
Name | Description |
---|---|
T | Source type of elements. |
Constructors
UnsafeRingQueue(T*, Int32)
Constructs container as view into memory.
Declaration
public UnsafeRingQueue(T*ptr, int capacity)
Parameters
Type | Name | Description |
---|---|---|
T* | ptr | |
Int32 | capacity |
UnsafeRingQueue(Int32, Allocator, NativeArrayOptions)
Constructs a new container with the specified capacity and type of memory allocation.
Declaration
public UnsafeRingQueue(int capacity, Allocator allocator, NativeArrayOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Container capacity. |
Allocator | allocator | A member of the Unity.Collections.Allocator enumeration. |
NativeArrayOptions | options | Memory should be cleared on allocation or left uninitialized. |
Fields
Allocator
Declaration
public Allocator Allocator
Field Value
Type | Description |
---|---|
Allocator |
Ptr
Declaration
public T*Ptr
Field Value
Type | Description |
---|---|
T* |
Properties
Capacity
Returns capacity of the container.
Declaration
public int Capacity { 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.
Warning: the IsCreated
property can't be used to determine whether a copy of a container is still valid.
If you dispose any copy of the container, the container storage is deallocated. However, the properties of
the other copies of the container (including the original) are not updated. As a result the IsCreated
property
of the copies still return true
even though the container storage has been deallocated.
IsEmpty
Reports whether container is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean | True if this container empty. |
Length
Returns number of items in the container.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Dequeue()
Dequeue item from the container.
Declaration
public T Dequeue()
Returns
Type | Description |
---|---|
T | Returns item from the container. |
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. |
Implements
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. |
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. |
TryEnqueue(T)
Try enqueuing value into the container. If container is full value won't be enqueued, and return result will be false.
Declaration
public bool TryEnqueue(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be appended. |
Returns
Type | Description |
---|---|
Boolean | Returns true if value was appended, otherwise returns false. |