Interface ILockingMechanism
Defines a mechanism for acquiring and managing read and write locks on resources.
Namespace: Umbraco.Cms.Core.Scoping
Assembly: Umbraco.Core.dll
Syntax
public interface ILockingMechanism
Remarks
Locks can be acquired lazily (deferred until actually needed) or eagerly (immediately).
The mechanism tracks locks by scope instance ID to support nested scopes.
Methods
View SourceClearLocks(Guid)
Clears all the locks held by a specific scope instance.
Declaration
void ClearLocks(Guid instanceId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | instanceId | Instance id of the scope whose locks should be cleared. |
EagerReadLock(Guid, params int[])
Eagerly acquires a read-lock using the default timeout.
Declaration
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
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
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
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
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
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
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
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
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
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
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
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. |