Class ScyllaQueue<T>.Builder
Fluent builder for constructing and optionally synchronizing a ScyllaQueue<T> with a discoverable, named-parameter configuration API.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaQueue<T>.Builder
Remarks
Obtain a builder via CreateBuilder(). Configure it with the fluent methods, then call Build() to get an IScyllaCollection<T> or BuildConcrete() to get the concrete ScyllaQueue<T> type directly (which throws if Synchronized(object) was called, since the concrete return type cannot represent a synchronized wrapper).
Default configuration if no methods are called: initial capacity 4,
auto-growing, unsynchronized.
// Minimal - default capacity, auto-growing, unsynchronized
var q1 = ScyllaQueue<int>.CreateBuilder().BuildConcrete();
// Fixed-capacity queue of 256 elements
var q2 = ScyllaQueue<string>.CreateBuilder()
.WithCapacity(256)
.FixedCapacity()
.BuildConcrete();
// Thread-safe queue with a shared sync root
var sharedLock = new object();
IScyllaCollection<Task> q3 = ScyllaQueue<Task>.CreateBuilder()
.WithCapacity(128)
.Synchronized(sharedLock)
.Build();
Methods
Build()
Builds the configured queue and returns it as an IScyllaCollection<T>.
Declaration
public IScyllaCollection<T> Build()
Returns
| Type | Description |
|---|---|
| IScyllaCollection<T> | When Synchronized(object) was called: a ScyllaQueue<T>.SynchronizedScyllaQueue wrapping the constructed queue, returned as IScyllaCollection<T>. Otherwise: the constructed ScyllaQueue<T> itself, also returned as IScyllaCollection<T>. |
BuildConcrete()
Builds the configured queue and returns it as the concrete ScyllaQueue<T> type, providing access to members not available through the interface (such as GetEnumerator(), Contains(T, IEqualityComparer<T>), and EnsureCapacity(int)).
Declaration
public ScyllaQueue<T> BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaQueue<T> | The configured unsynchronized ScyllaQueue<T> instance. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Synchronized(object) was called, because a synchronized wrapper cannot be expressed as the concrete ScyllaQueue<T> return type. Call Build() instead and cast through IScyllaCollection<T>. |
FixedCapacity(bool)
Enables or disables fixed-capacity mode on the queue being built.
In fixed-capacity mode the buffer never grows and TryEnqueue(T) returns
false when the queue is full.
Declaration
public ScyllaQueue<T>.Builder FixedCapacity(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value |
|
Returns
| Type | Description |
|---|---|
| ScyllaQueue<T>.Builder | This builder instance for method chaining. |
Synchronized(object)
Configures the builder to wrap the constructed queue in a ScyllaQueue<T>.SynchronizedScyllaQueue that serializes all operations through a lock.
Declaration
public ScyllaQueue<T>.Builder Synchronized(object syncRoot = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | syncRoot | An optional external lock object. When |
Returns
| Type | Description |
|---|---|
| ScyllaQueue<T>.Builder | This builder instance for method chaining. |
WithCapacity(int)
Sets the initial capacity of the queue's backing circular buffer.
Declaration
public ScyllaQueue<T>.Builder WithCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial buffer capacity. Must be at least |
Returns
| Type | Description |
|---|---|
| ScyllaQueue<T>.Builder | This builder instance for method chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |