Class ScyllaRingBufferDOTS<T>.Builder
Fluent builder for configuring and constructing ScyllaRingBufferDOTS<T> instances.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaRingBufferDOTS<T>.Builder
Remarks
Provides a discoverable, named-parameter alternative to the positional constructor. The allocator must be set via WithAllocator(Allocator) before calling Build() or BuildConcrete(); failing to do so throws an InvalidOperationException.
Unlike ScyllaRingBuffer<T>.Builder, this builder does not support a
Synchronized option because ScyllaRingBufferDOTS<T> has no synchronized
wrapper. Both Build() and BuildConcrete() return the same concrete
struct type and are functionally identical; BuildConcrete() exists for API
consistency with other Scylla collection builders.
Methods
Build()
Builds and returns the configured ScyllaRingBufferDOTS<T> instance.
Declaration
public ScyllaRingBufferDOTS<T> Build()
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T> | The fully configured and allocated ScyllaRingBufferDOTS<T> instance. |
Remarks
Validates that WithAllocator(Allocator) has been called before constructing the ring buffer. The returned struct owns native memory and must be disposed via Dispose() when no longer needed.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithAllocator(Allocator) has not been called prior to building. |
BuildConcrete()
Builds and returns the concrete ScyllaRingBufferDOTS<T> instance. Functionally identical to Build() since this type has no synchronized wrapper variant.
Declaration
public ScyllaRingBufferDOTS<T> BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T> | The fully configured and allocated ScyllaRingBufferDOTS<T> instance. |
Remarks
This method exists for API consistency with BuildConcrete() so that builder-pattern callers can substitute collection types without changing call sites. The returned struct owns native memory and must be disposed via Dispose() when no longer needed.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithAllocator(Allocator) has not been called prior to building. |
OverwriteOnFull(bool)
Configures whether writing to a full buffer silently overwrites the oldest element.
Declaration
public ScyllaRingBufferDOTS<T>.Builder OverwriteOnFull(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value |
|
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T>.Builder | This builder instance for method chaining. |
Remarks
When enabled (value is true), calls to TryAdd(T)
always succeed - even when the buffer is at capacity - by discarding the oldest element and
advancing the head. When disabled (the default), write operations return false when the
buffer is full.
WithAllocator(Allocator)
Sets the Unity native-memory allocator to use for the backing Unity.Collections.NativeArray<T>. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaRingBufferDOTS<T>.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | The native-memory allocator to use. Must not be Unity.Collections.Allocator.None. |
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T>.Builder | This builder instance for method chaining. |
Remarks
Allocator selection guidance:
-
Allocator.Persistent- long-lived buffer recommended for most game scenarios. -
Allocator.TempJob- buffer used within a single frame across jobs; must be disposed within four frames. -
Allocator.Temp- shortest-lived buffer; must be disposed within the same frame.
Allocator.None is not a valid choice and will throw immediately.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
WithCapacity(int)
Sets the fixed maximum capacity of the ring buffer.
Declaration
public ScyllaRingBufferDOTS<T>.Builder WithCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The maximum number of elements the ring buffer can hold. Must be |
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T>.Builder | This builder instance for method chaining. |
Remarks
Values less than 1 are not clamped here (an exception is thrown); however, the
constructor clamps values below 1 to 1. The builder validates non-negative
inputs with a distinct exception message to surface configuration errors early.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
WithNativeArrayOptions(NativeArrayOptions)
Sets the initialization options for the backing Unity.Collections.NativeArray<T>.
Declaration
public ScyllaRingBufferDOTS<T>.Builder WithNativeArrayOptions(NativeArrayOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArrayOptions | options | The Unity.Collections.NativeArrayOptions to pass to the Unity.Collections.NativeArray<T> constructor. Defaults to Unity.Collections.NativeArrayOptions.UninitializedMemory if not called. |
Returns
| Type | Description |
|---|---|
| ScyllaRingBufferDOTS<T>.Builder | This builder instance for method chaining. |
Remarks
-
Unity.Collections.NativeArrayOptions.UninitializedMemory (default) - fastest allocation;
memory may contain arbitrary data. Safe because the ring buffer's logical state
(
_count = 0) ensures uninitialized slots are never read. - Unity.Collections.NativeArrayOptions.ClearMemory - zeroes the allocated memory. Useful when debugging or when initial zero values are semantically meaningful.