Interface WorkflowLock
public interface WorkflowLock
Workflow lock is an alternative to
Lock that is deterministic
and compatible with Temporal's concurrency model. API is designed to be used in a workflow code
only. It is not allowed to be used in an activity code.
In Temporal concurrency model, only one thread in a workflow code can execute at a time.
-
Method Summary
-
Method Details
-
lock
void lock()Acquires the lock.- Throws:
CanceledFailure- if thread (or currentCancellationScopewas canceled).
-
tryLock
boolean tryLock()Acquires the lock only if it is free at the time of invocation.- Returns:
- true if the lock was acquired and false otherwise
-
tryLock
Acquires the lock if it is free within the given waiting time.- Returns:
- true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.
- Throws:
CanceledFailure- if thread (or currentCancellationScopewas canceled).
-
unlock
void unlock()Releases the lock. -
isHeld
boolean isHeld()Checks if a lock is held.- Returns:
- true if the lock is held and false otherwise.
-