Class ScyllaMap<TKey, TValue>.SynchronizedScyllaMap
Thread-safe wrapper around ScyllaMap<TKey, TValue> that synchronizes all operations using a lock.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaMap<TKey, TValue>.SynchronizedScyllaMap : IScyllaMap<TKey, TValue>, IScyllaCollection
Constructors
SynchronizedScyllaMap(ScyllaMap<TKey, TValue>, object)
Initializes a new instance of the synchronized wrapper around the specified map.
Declaration
public SynchronizedScyllaMap(ScyllaMap<TKey, TValue> inner, object syncRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaMap<TKey, TValue> | inner | The map to wrap. Must not be null. |
| object | syncRoot | The lock object to use for synchronization. If null, a new private lock is created. |
Properties
Capabilities
Gets the capability flags supported by this map instance. Returned without acquiring the lock because capabilities are immutable after construction.
Declaration
public ScyllaCollectionCapabilities Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionCapabilities |
Capacity
Gets the current number of internal slots (power of two). Acquires the lock.
Declaration
public int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
Count
Gets the number of live key/value pairs currently stored in the map. Acquires the lock.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsEmpty
Gets whether the map contains no entries. Acquires the lock.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsFixedCapacity
Gets whether the wrapped map was constructed with fixed-capacity mode. Returned without acquiring the lock because this value is immutable after construction.
Declaration
public bool IsFixedCapacity { get; }
Property Value
| Type | Description |
|---|---|
| bool |
SyncRoot
Gets the monitor lock object that serializes all operations on this wrapper. Non-null and stable for the lifetime of the instance.
Declaration
public object SyncRoot { get; }
Property Value
| Type | Description |
|---|---|
| object |
ThreadSafety
Gets Synchronized, indicating that all operations on this wrapper are protected by a lock.
Declaration
public ScyllaCollectionThreadSafety ThreadSafety { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionThreadSafety |
Methods
Clear()
Removes all entries from the wrapped map under the lock.
Declaration
public void Clear()
ContainsKey(TKey)
Returns true if the map contains an entry for key. Acquires the lock.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to locate. Must not be |
Returns
| Type | Description |
|---|---|
| bool |
|
EnsureCapacity(int)
Ensures the wrapped map can hold at least minCapacity entries without
resizing. Acquires the lock before delegating to EnsureCapacity(int).
Declaration
public void EnsureCapacity(int minCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minCapacity | The minimum number of entries the map must be able to hold. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the wrapped map was constructed with fixed-capacity mode and the requested capacity exceeds the current table size. |
TryAdd(TKey, TValue)
Attempts to insert a new key/value pair under the lock.
Returns false if the key already exists or capacity constraints prevent insertion.
Declaration
public bool TryAdd(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to add. Must not be |
| TValue | value | The value to associate with |
Returns
| Type | Description |
|---|---|
| bool |
|
TryGetValue(TKey, out TValue)
Attempts to retrieve the value for key under the lock.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to look up. Must not be |
| TValue | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
TryRemove(TKey)
Attempts to remove the entry for key under the lock.
Returns false if the key is not present.
Declaration
public bool TryRemove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to remove. Must not be |
Returns
| Type | Description |
|---|---|
| bool |
|
TryRemove(TKey, out TValue)
Attempts to remove the entry for key and retrieve its associated value
under the lock.
Declaration
public bool TryRemove(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to remove. Must not be |
| TValue | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
TrySet(TKey, TValue)
Attempts to update the value for an existing key under the lock.
Returns false if the key does not exist; does not insert a new entry.
Declaration
public bool TrySet(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key whose value should be updated. Must not be |
| TValue | value | The new value to associate with |
Returns
| Type | Description |
|---|---|
| bool |
|