Interface WorkflowThread

All Superinterfaces:
CancellationScope, Runnable
All Known Implementing Classes:
RootWorkflowThreadImpl

public interface WorkflowThread extends CancellationScope
Thread that is scheduled deterministically by DeterministicRunner.
  • Method Details

    • await

      static void await(String reason, Supplier<Boolean> unblockCondition) throws DestroyWorkflowThreadError
      Block current thread until unblockCondition is evaluated to true. This method is intended for framework level libraries, never use directly in a workflow implementation.
      Parameters:
      reason - reason for blocking
      unblockCondition - condition that should return true to indicate that thread should unblock.
      Throws:
      CanceledFailure - if thread (or current cancellation scope was canceled).
      DestroyWorkflowThreadError - if thread was asked to be destroyed.
    • newThread

      static WorkflowThread newThread(Runnable runnable, boolean detached)
      Creates a new thread instance.
      Parameters:
      runnable - thread function to run
      detached - If this thread is detached from the parent CancellationScope
      Returns:
    • newThread

      static WorkflowThread newThread(Runnable runnable, boolean detached, String name)
    • start

      void start()
    • isStarted

      boolean isStarted()
    • setName

      void setName(String name)
    • getName

      String getName()
    • getId

      long getId()
    • getPriority

      int getPriority()
    • getStackTrace

      String getStackTrace()
    • getRunner

      io.temporal.internal.sync.DeterministicRunnerImpl getRunner()
    • getWorkflowContext

      io.temporal.internal.sync.SyncWorkflowContext getWorkflowContext()
    • runUntilBlocked

      boolean runUntilBlocked(long deadlockDetectionTimeoutMs)
      Parameters:
      deadlockDetectionTimeoutMs - maximum time in milliseconds the thread can run before calling yield.
      Returns:
      true if coroutine made some progress.
    • lockDeadlockDetector

      NonIdempotentHandle lockDeadlockDetector()
      Disables deadlock detector on this thread
      Returns:
      a handle that must be used to unlock the deadlock detector back
    • getUnhandledException

      Throwable getUnhandledException()
    • isDone

      boolean isDone()
    • stopNow

      Future<?> stopNow()
    • addStackTrace

      void addStackTrace(StringBuilder result)
    • yield

      void yield(String reason, Supplier<Boolean> unblockCondition) throws DestroyWorkflowThreadError
      Throws:
      DestroyWorkflowThreadError
    • exit

      static void exit()
      Stop executing all workflow threads and puts DeterministicRunner into closed state. To be called only from a workflow thread.
    • exitThread

      void exitThread()
    • setThreadLocal

      <T> void setThreadLocal(WorkflowThreadLocalInternal<T> key, T value)
    • getThreadLocal

      <T> Optional<Optional<T>> getThreadLocal(WorkflowThreadLocalInternal<T> key)
    • getWorkflowThreadContext

      io.temporal.internal.sync.WorkflowThreadContext getWorkflowThreadContext()