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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean isHeld()
      Checks if a lock is held.
      void lock()
      Acquires the lock.
      boolean tryLock()
      Acquires the lock only if it is free at the time of invocation.
      boolean tryLock​(java.time.Duration timeout)
      Acquires the lock if it is free within the given waiting time.
      void unlock()
      Releases the lock.
    • Method Detail

      • 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​(java.time.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.