Package io.temporal.internal.sync
Interface WorkflowThread
-
- All Superinterfaces:
CancellationScope
,java.lang.Runnable
public interface WorkflowThread extends CancellationScope
Thread that is scheduled deterministically byDeterministicRunner
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addStackTrace(java.lang.StringBuilder result)
static void
await(java.lang.String reason, java.util.function.Supplier<java.lang.Boolean> unblockCondition)
Block current thread until unblockCondition is evaluated to true.static <R> void
exit(R value)
Stop executing all workflow threads and putsDeterministicRunner
into closed state.<R> void
exitThread(R value)
long
getId()
java.lang.String
getName()
int
getPriority()
io.temporal.internal.sync.DeterministicRunnerImpl
getRunner()
java.lang.String
getStackTrace()
<T> java.util.Optional<T>
getThreadLocal(WorkflowThreadLocalInternal<T> key)
java.lang.Throwable
getUnhandledException()
io.temporal.internal.sync.SyncWorkflowContext
getWorkflowContext()
WorkflowThreadContext
getWorkflowThreadContext()
boolean
isDone()
boolean
isStarted()
static WorkflowThread
newThread(java.lang.Runnable runnable, boolean detached)
Creates a new thread instance.static WorkflowThread
newThread(java.lang.Runnable runnable, boolean detached, java.lang.String name)
boolean
runUntilBlocked(long deadlockDetectionTimeoutMs)
void
setName(java.lang.String name)
<T> void
setThreadLocal(WorkflowThreadLocalInternal<T> key, T value)
void
start()
java.util.concurrent.Future<?>
stopNow()
void
yield(java.lang.String reason, java.util.function.Supplier<java.lang.Boolean> unblockCondition)
-
Methods inherited from interface io.temporal.workflow.CancellationScope
cancel, cancel, getCancellationReason, getCancellationRequest, isCancelRequested, isDetached
-
-
-
-
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 blockingunblockCondition
- 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 rundetached
- If this thread is detached from the parentCancellationScope
- 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 putsDeterministicRunner
into closed state. To be called only from a workflow thread.- Parameters:
value
- accessible throughDeterministicRunner.getExitValue()
.
-
exitThread
<R> void exitThread(R value)
-
setThreadLocal
<T> void setThreadLocal(WorkflowThreadLocalInternal<T> key, T value)
-
getThreadLocal
<T> java.util.Optional<T> getThreadLocal(WorkflowThreadLocalInternal<T> key)
-
getWorkflowThreadContext
WorkflowThreadContext getWorkflowThreadContext()
-
-