Class ScyllaBitArray.SynchronizedScyllaBitArray
Thread-safe decorator that wraps a ScyllaBitArray and synchronizes every operation using a monitor lock on SyncRoot.
Implements
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaBitArray.SynchronizedScyllaBitArray : IScyllaCollection
Remarks
All mutating and read operations acquire SyncRoot before delegating to the inner ScyllaBitArray. Compound operations (read-modify-write) are therefore atomic with respect to other callers using the same wrapper instance.
If multiple threads share the underlying ScyllaBitArray directly (bypassing this wrapper), no synchronization guarantee is provided. Use this wrapper as the sole point of access when thread safety is required.
Constructors
SynchronizedScyllaBitArray(ScyllaBitArray, object)
Initializes a new ScyllaBitArray.SynchronizedScyllaBitArray wrapping
inner and locking on syncRoot.
Declaration
public SynchronizedScyllaBitArray(ScyllaBitArray inner, object syncRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArray | inner | The ScyllaBitArray to wrap. Must not be |
| object | syncRoot | The lock object to use. A new private |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
Capabilities
Feature/capability flags reported by this collection instance.
Declaration
public ScyllaCollectionCapabilities Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionCapabilities |
Remarks
Reports HasCapacity because the array has a fixed capacity, and SupportsContains because membership testing is provided by Get(int).
Capacity
The total number of bits this array can hold, read under the lock.
Declaration
public int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| int | The effective bit capacity, rounded up to a multiple of 64. |
Count
The number of bits currently set to 1, read under the lock.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The synchronized population count. |
IsEmpty
Returns true when no bits are set, read under the lock.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
SyncRoot
Gets the synchronization root object used to externally coordinate multi-step operations with this collection.
Declaration
public 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
public 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
And(ScyllaBitArray)
Performs an in-place bitwise AND with other, under the lock.
Declaration
public void And(ScyllaBitArray other)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArray | other | The bit array to AND with. Must not be |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
See Also
Clear()
Sets all bits to 0 and resets the population count to zero, under the lock.
Declaration
public void Clear()
See Also
Get(int)
Returns true if the bit at index is set, under the lock.
Declaration
public bool Get(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based bit index in the range |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
See Also
Not()
Inverts all bits in-place, under the lock.
Declaration
public void Not()
See Also
Or(ScyllaBitArray)
Performs an in-place bitwise OR with other, under the lock.
Declaration
public void Or(ScyllaBitArray other)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArray | other | The bit array to OR with. Must not be |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
See Also
PopCount()
Returns the population count (number of set bits), under the lock.
Declaration
public int PopCount()
Returns
| Type | Description |
|---|---|
| int | The number of set bits in the range |
See Also
Set(int)
Sets the bit at index to 1, under the lock.
Declaration
public void Set(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based bit index in the range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
See Also
Set(int, bool)
Sets or clears the bit at index according to
value, under the lock.
Declaration
public void Set(int index, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based bit index in the range |
| bool | value |
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
See Also
SetAll()
Sets all bits to 1, under the lock.
Declaration
public void SetAll()
See Also
Toggle(int)
Flips the bit at index, under the lock.
Declaration
public void Toggle(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based bit index in the range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
See Also
Unset(int)
Clears the bit at index to 0, under the lock.
Declaration
public void Unset(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based bit index in the range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
See Also
Xor(ScyllaBitArray)
Performs an in-place bitwise XOR with other, under the lock.
Declaration
public void Xor(ScyllaBitArray other)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArray | other | The bit array to XOR with. Must not be |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |