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

    Modifier and Type
    Method
    Description
    boolean
    Checks if a lock is held.
    void
    Acquires the lock.
    boolean
    Acquires the lock only if it is free at the time of invocation.
    boolean
    tryLock(Duration timeout)
    Acquires the lock if it is free within the given waiting time.
    void
    Releases the lock.
  • Method Details

    • lock

      void lock()
      Acquires the lock.
      Throws:
      CanceledFailure - if thread (or current CancellationScope was 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

      boolean tryLock(Duration timeout)
      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 current CancellationScope was 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.