Class LockingMechanism
Mechanism for handling read and write locks.
Inheritance
Namespace: Umbraco.Cms.Core.Scoping
Assembly: Umbraco.Core.dll
Syntax
public class LockingMechanism : ILockingMechanism
Constructors
View SourceLockingMechanism(IDistributedLockingMechanismFactory, ILogger<LockingMechanism>)
Initializes a new instance of the LockingMechanism class.
Declaration
public LockingMechanism(IDistributedLockingMechanismFactory distributedLockingMechanismFactory, ILogger<LockingMechanism> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| IDistributedLockingMechanismFactory | distributedLockingMechanismFactory | The factory for creating distributed locking mechanisms. |
| ILogger<LockingMechanism> | logger | The logger for logging lock-related messages. |
Methods
View SourceClearLocks(Guid)
Clears all the locks held by a specific scope instance.
Declaration
public void ClearLocks(Guid instanceId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope whose locks should be cleared. |
Dispose()
Declaration
public void Dispose()
EagerReadLock(Guid, params int[])
Eagerly acquires a read-lock using the default timeout.
Declaration
public void EagerReadLock(Guid instanceId, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| int[] | lockIds | Array of lock object identifiers. |
EagerReadLock(Guid, TimeSpan?, params int[])
Eagerly acquires a read-lock
Declaration
public void EagerReadLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | |
| TimeSpan? | timeout | Timeout for the lock |
| int[] | lockIds |
EagerWriteLock(Guid, params int[])
Eagerly acquires a write-lock using the default timeout.
Declaration
public void EagerWriteLock(Guid instanceId, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| int[] | lockIds | Array of lock object identifiers. |
EagerWriteLock(Guid, TimeSpan?, params int[])
Eagerly acquires a write-lock.
Declaration
public void EagerWriteLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| TimeSpan? | timeout | Timeout for the lock. |
| int[] | lockIds | Array of lock object identifiers. |
EnsureLocks(Guid)
Acquires all the non-eagerly (lazily) requested locks.
Declaration
public void EnsureLocks(Guid scopeInstanceId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | scopeInstanceId | Instance id of the scope whose pending locks should be acquired. |
EnsureLocksCleared(Guid)
Ensures all locks have been cleared for a specific scope instance, throwing if any remain.
Declaration
public void EnsureLocksCleared(Guid instanceId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope to verify. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when locks have not been properly cleared. |
GetReadLocks()
Gets the dictionary of read locks held by scope instances.
Declaration
public Dictionary<Guid, Dictionary<int, int>>? GetReadLocks()
Returns
| Type | Description |
|---|---|
| Dictionary<Guid, Dictionary<int, int>> | A dictionary mapping scope instance IDs to their read lock counts by lock ID, or |
GetWriteLocks()
Gets the dictionary of write locks held by scope instances.
Declaration
public Dictionary<Guid, Dictionary<int, int>>? GetWriteLocks()
Returns
| Type | Description |
|---|---|
| Dictionary<Guid, Dictionary<int, int>> | A dictionary mapping scope instance IDs to their write lock counts by lock ID, or |
ReadLock(Guid, params int[])
Read-locks some lock objects lazily using the default timeout.
Declaration
public void ReadLock(Guid instanceId, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| int[] | lockIds | Array of lock object identifiers. |
ReadLock(Guid, TimeSpan?, params int[])
Read-locks some lock objects lazily.
Declaration
public void ReadLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock |
| TimeSpan? | timeout | Timeout for the lock |
| int[] | lockIds | Array of lock object identifiers. |
WriteLock(Guid, params int[])
Write-locks some lock objects lazily using the default timeout.
Declaration
public void WriteLock(Guid instanceId, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| int[] | lockIds | Array of object identifiers. |
WriteLock(Guid, TimeSpan?, params int[])
Write-locks some lock objects lazily.
Declaration
public void WriteLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope who is requesting the lock. |
| TimeSpan? | timeout | Timeout for the lock. |
| int[] | lockIds | Array of object identifiers. |