Interface IScyllaCollection
Base interface for all non-generic Scylla collection types. Provides a minimal, shape-agnostic contract that allows heterogeneous collections to be handled uniformly - for example, stored in a list, iterated, cleared, or introspected - without requiring knowledge of the concrete element type or collection topology.
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaCollection
Remarks
This interface is deliberately narrow. High-performance, shape-specific operations (e.g. enqueue, push, write) are defined on the typed extension IScyllaCollection<T> and on concrete classes such as ScyllaQueue<T>, ScyllaStack<T>, and ScyllaRingBuffer<T>.
Thread-safety model: Core collection implementations are typically
Unsynchronized for maximum performance.
Thread-safe usage is provided via explicit synchronized wrappers (e.g.
ScyllaQueue<T>.SynchronizedScyllaQueue) which report
Synchronized and expose a non-null
SyncRoot. A third level, LockFree,
is reserved for specialized implementations built on atomic operations.
Feature detection: Use the Capabilities flags instead of type-casting to determine which optional operations a collection instance supports. For example, check SupportsPeek before calling TryPeek(out T) through the typed interface.
Properties
Capabilities
Gets the feature and capability flags supported by this collection instance.
Declaration
ScyllaCollectionCapabilities Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionCapabilities | A bitfield of ScyllaCollectionCapabilities flags describing which optional operations the concrete instance supports. The value None indicates that only the base contract (Count, IsEmpty, Clear()) is available. |
Remarks
Use Capabilities for feature detection in place of type-casting. For example:
if ((collection.Capabilities & ScyllaCollectionCapabilities.SupportsPeek) != 0)
{
// safe to call TryPeek through IScyllaCollection<T>
}
Synchronized wrappers cache the capability flags of their inner collection at construction time, so the value returned is stable and does not require synchronization.
See Also
Count
Gets the number of items currently contained in the collection.
Declaration
int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | A non-negative integer representing the current element count.
Returns |
Remarks
On unsynchronized collections, Count is not thread-safe and may return a stale
value when accessed concurrently. On synchronized wrappers, reading Count is
protected by the internal lock.
IsEmpty
Gets a value indicating whether the collection contains no items.
Declaration
bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
This is a convenience property equivalent to Count == 0. Prefer it over comparing
Count directly when the actual count is not needed, as some implementations may
compute it more efficiently.
SyncRoot
Gets the synchronization root object used to externally coordinate multi-step operations with this collection.
Declaration
object SyncRoot { get; }
Property Value
| Type | Description |
|---|---|
| object | A non-null object suitable for use with |
Remarks
When this collection is a synchronized wrapper, SyncRoot must be non-null and
stable for the entire lifetime of the wrapper. All internal operations on the wrapper
must lock on this same object. This allows callers to perform atomic multi-step
sequences:
lock (collection.SyncRoot)
{
if (!collection.IsEmpty)
typedCollection.TryRemove(out var item);
}
For unsynchronized collections (SyncRoot == null), callers are responsible for
supplying and consistently applying their own external synchronization mechanism.
A null SyncRoot does not mean the collection is thread-safe;
consult ThreadSafety for the authoritative guarantee.
See Also
ThreadSafety
Gets the thread-safety guarantees provided by this collection instance.
Declaration
ScyllaCollectionThreadSafety ThreadSafety { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionThreadSafety | A ScyllaCollectionThreadSafety value indicating whether the collection is unsynchronized, synchronized via a lock, or safe for lock-free concurrent access. Most core implementations return Unsynchronized. Synchronized wrappers return Synchronized. |
Remarks
Always check this property (or SyncRoot) before assuming a collection is
safe for concurrent use. Do not rely solely on the absence of a non-null SyncRoot
to infer thread safety; use this property as the authoritative source.
See Also
Methods
Clear()
Removes all items from the collection and resets it to an empty state.
Declaration
void Clear()
Remarks
Implementations that store reference-type elements should null out internal slots after
clearing to avoid retaining object references and preventing garbage collection.
After Clear returns, Count must be 0 and
IsEmpty must be true.
On synchronized wrappers this operation is protected by the collection's internal lock. On unsynchronized collections, callers are responsible for external coordination.