# UnsafeRingQueue<T>

> A fixed-size circular buffer.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections.LowLevel.Unsafe](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct UnsafeRingQueue<T> : INativeDisposable, IDisposable where T : unmanaged
```

## Fields

| Value                                                                                                        | Description                                       |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
| [Allocator](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/allocator.md) | The allocator used to create the internal buffer. |
| [Ptr](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/ptr.md)             | The internal buffer where the content is stored.  |

## Static Fields

| Value                                                                                                            | Description                                                     |
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [MaxCapacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/maxcapacity.md) | The maximum number of elements this type of container can hold. |

## Constructors

| Constructor                                                                                                                                                                                                                                                                      | Description                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| [UnsafeRingQueue\`1(\`0\*,System.Int32)](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/ctor.md#unsaferingqueue\(0*-int\))                                                                                                                   | Initializes and returns an instance of UnsafeRingQueue which aliasing an existing buffer. |
| [UnsafeRingQueue\`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/ctor.md#unsaferingqueue\(int-allocatorhandle-nativearrayoptions\)) | Initializes and returns an instance of UnsafeRingQueue.                                   |

## Properties

| Property                                                                                                     | Description                                                      |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/capacity.md)   | The number of elements that fit in the internal buffer.          |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/iscreated.md) | Whether this queue has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/isempty.md)     | Whether the queue is empty.                                      |
| [Length](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/length.md)       | The number of elements currently in this queue.                  |

## Methods

| Method                                                                                                         | Description                                         |
| -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [Dequeue](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/dequeue.md)       | Removes the element from the end of the queue.      |
| [Dispose](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/dispose.md)       | Releases all resources (memory and safety handles). |
| [Enqueue](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/enqueue.md)       | Adds an element at the front of the queue.          |
| [TryDequeue](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/trydequeue.md) | Removes the element from the end of the queue.      |
| [TryEnqueue](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsaferingqueue1/tryenqueue.md) | Adds an element at the front of the queue.          |
