Interface WorkflowThread

  • All Superinterfaces:
    CancellationScope, java.lang.Runnable

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

      • await

        static void await​(java.lang.String reason,
                          java.util.function.Supplier<java.lang.Boolean> unblockCondition)
                   throws io.temporal.internal.sync.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).
        io.temporal.internal.sync.DestroyWorkflowThreadError - if thread was asked to be destroyed.
      • newThread

        static WorkflowThread newThread​(java.lang.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​(java.lang.Runnable runnable,
                                        boolean detached,
                                        java.lang.String name)
      • start

        void start()
      • isStarted

        boolean isStarted()
      • setName

        void setName​(java.lang.String name)
      • getName

        java.lang.String getName()
      • getId

        long getId()
      • getPriority

        int getPriority()
      • getStackTrace

        java.lang.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.
      • getUnhandledException

        java.lang.Throwable getUnhandledException()
      • isDone

        boolean isDone()
      • stopNow

        java.util.concurrent.Future<?> stopNow()
      • addStackTrace

        void addStackTrace​(java.lang.StringBuilder result)
      • yield

        void yield​(java.lang.String reason,
                   java.util.function.Supplier<java.lang.Boolean> unblockCondition)
            throws io.temporal.internal.sync.DestroyWorkflowThreadError
        Throws:
        io.temporal.internal.sync.DestroyWorkflowThreadError
      • exit

        static <R> void exit​(R value)
        Stop executing all workflow threads and puts DeterministicRunner into closed state. To be called only from a workflow thread.
        Parameters:
        value - accessible through DeterministicRunner.getExitValue().
      • exitThread

        <R> void exitThread​(R value)