LockAndGetFenceAsync Method
LockAndGetFenceAsync(LockContext)
Acquires the lock and returns the fencing token assigned to the specified lockContext
context for this lock acquisition.
Declaration
Task<long> LockAndGetFenceAsync(LockContext lockContext)
Parameters
LockContext | lockContext | The LockContext. |
Returns
Task<long> | The fencing token if the lock was acquired; otherwise InvalidFence. |
Remarks
If the lock is acquired in a reentrant way, the same fencing token is returned, or the LockAsync(LockContext) call can throw LockAcquireLimitReachedException if the lock acquisition limit is already reached.
Fencing tokens are monotonic numbers that are incremented each time the lock switches from the free state to the acquired state. They are simply used for ordering lock holders. A lock holder can pass its fencing to the shared resource to fence off previous lock holders. When this resource receives an operation, it can validate the fencing token in the operation.