> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksatomicqueue-1.md).

# Class ksAtomicQueue\<T>

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Wraps a Queue to make all read/write operations thread safe.

```csharp
public class ksAtomicQueue<T>
```

#### Type Parameters

`T`

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksAtomicQueue\<T>](/reactor/api-reference/ks.reactor/ks.reactor.ksatomicqueue-1.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Properties

### Count <a href="#ks_reactor_ksatomicqueue_1_count" id="ks_reactor_ksatomicqueue_1_count"></a>

Number of values in the queue.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

## Methods

### Clear() <a href="#ks_reactor_ksatomicqueue_1_clear" id="ks_reactor_ksatomicqueue_1_clear"></a>

Removes everything from the queue.

```csharp
public void Clear()
```

### Dequeue() <a href="#ks_reactor_ksatomicqueue_1_dequeue" id="ks_reactor_ksatomicqueue_1_dequeue"></a>

Removes the first value in the queue.

```csharp
public T Dequeue()
```

#### Returns

T

Value removed from the queue.

### Enqueue(T) <a href="#ks_reactor_ksatomicqueue_1_enqueue__0" id="ks_reactor_ksatomicqueue_1_enqueue__0"></a>

Adds a value to the end of the queue.

```csharp
public void Enqueue(T value)
```

#### Parameters

`value` T

Value to add.

### Peek() <a href="#ks_reactor_ksatomicqueue_1_peek" id="ks_reactor_ksatomicqueue_1_peek"></a>

Returns the first value without removing it from the queue.

```csharp
public T Peek()
```

#### Returns

T

First value in queue.

### ToArray() <a href="#ks_reactor_ksatomicqueue_1_toarray" id="ks_reactor_ksatomicqueue_1_toarray"></a>

Converts the queueto an array.

```csharp
public T[] ToArray()
```

#### Returns

T\[]

An array of all the data in the queue.

### TryDequeue(out T) <a href="#ks_reactor_ksatomicqueue_1_trydequeue__0" id="ks_reactor_ksatomicqueue_1_trydequeue__0"></a>

Tries to remove and return the object at the beginning of the queue.

```csharp
public bool TryDequeue(out T outValue)
```

#### Parameters

`outValue` T

If the operation was successful, outValue contains the object removed. If no object was available to be removed, the value is the default T value.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if an element was removed and returned from the beginning of the queue.
