Class ScyllaTypeMap.SynchronizedScyllaTypeMap
Thread-safe wrapper around ScyllaTypeMap that synchronizes all operations using a lock.
Implements
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaTypeMap.SynchronizedScyllaTypeMap : IScyllaCollection
Constructors
SynchronizedScyllaTypeMap(ScyllaTypeMap, object)
Initializes a new instance of the synchronized wrapper around the specified type map.
Declaration
public SynchronizedScyllaTypeMap(ScyllaTypeMap inner, object syncRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaTypeMap | inner | The type 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
BucketDefaultCapacity
Gets the default initial capacity used for each per-type bucket in the wrapped type map. Returned without acquiring the lock because this value is immutable after construction.
Declaration
public int BucketDefaultCapacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
Capabilities
Gets the capability flags supported by this type map instance. Returned without acquiring the lock because capabilities are immutable after construction.
Declaration
public ScyllaCollectionCapabilities Capabilities { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaCollectionCapabilities |
Count
Gets the total number of (type, id) entries stored across all type buckets. Acquires the lock.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsEmpty
Gets whether the type map contains no entries. Acquires the lock.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsFixedCapacity
Gets whether the wrapped type 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 |
TypeCapacity
Gets the current capacity of the internal type table (number of slots). Acquires the lock.
Declaration
public int TypeCapacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
TypeCount
Gets the number of distinct type buckets currently registered in the wrapped type map. Acquires the lock.
Declaration
public int TypeCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Removes all entries from all type buckets in the wrapped type map, then removes the buckets themselves. Acquires the lock.
Declaration
public void Clear()
ClearType<T>()
Clears all entries for the bucket associated with T and removes the
bucket from the type table. Acquires the lock.
Declaration
public int ClearType<T>()
Returns
| Type | Description |
|---|---|
| int | The number of entries that were removed. Returns |
Type Parameters
| Name | Description |
|---|---|
| T | The value type whose bucket should be cleared. |
ContainsType<T>()
Returns true if the type map currently has a bucket registered for
T. Acquires the lock.
Declaration
public bool ContainsType<T>()
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type whose bucket to check for. |
Contains<T>(uint)
Returns true if the entry (T, id) exists.
Acquires the lock.
Declaration
public bool Contains<T>(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The numeric ID to locate within the bucket for |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type of the bucket to search. |
CountOf<T>()
Returns the number of entries currently stored in the bucket for T.
Acquires the lock.
Declaration
public int CountOf<T>()
Returns
| Type | Description |
|---|---|
| int | The number of entries in the bucket for |
Type Parameters
| Name | Description |
|---|---|
| T | The value type whose bucket count to return. |
GetDiagnosticEntries(List<DiagnosticEntry>)
Appends one ScyllaTypeMap.DiagnosticEntry per stored (type, id) entry to the given list and returns the number of entries appended. Acquires the lock. Diagnostic use only; boxes every stored value and must never be called from hot paths.
Declaration
public int GetDiagnosticEntries(List<ScyllaTypeMap.DiagnosticEntry> results)
Parameters
| Type | Name | Description |
|---|---|---|
| List<ScyllaTypeMap.DiagnosticEntry> | results | The list to append entries to. Must not be null. |
Returns
| Type | Description |
|---|---|
| int | The number of entries appended |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
TryAdd<T>(uint, T)
Attempts to add a new entry under (T, id).
Returns false if the entry already exists or capacity constraints prevent insertion.
Acquires the lock.
Declaration
public bool TryAdd<T>(uint id, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The ID to associate with |
| T | value | The value to store. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type of the bucket to insert into. |
TryGet<T>(uint, out T)
Attempts to retrieve the value stored under (T, id).
Acquires the lock.
Declaration
public bool TryGet<T>(uint id, out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The ID to look up within the bucket for |
| T | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type of the bucket to search. |
TryRemove<T>(uint, out T)
Attempts to remove the entry stored under (T, id)
and retrieve its value. Acquires the lock.
Declaration
public bool TryRemove<T>(uint id, out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The ID to remove. |
| T | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type of the bucket to remove from. |
TrySet<T>(uint, T)
Inserts or updates the entry for (T, id) (upsert).
If the entry exists it is updated; otherwise it is added. Returns false only if a new
entry must be added but capacity constraints prevent insertion. Acquires the lock.
Declaration
public bool TrySet<T>(uint id, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The ID whose value should be set. |
| T | value | The value to store. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The value type of the bucket to update. |