Package io.temporal.internal.sync
Interface WorkflowThread
-
- All Superinterfaces:
CancellationScope,java.lang.Runnable
- All Known Implementing Classes:
RootWorkflowThreadImpl
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 voidaddStackTrace(java.lang.StringBuilder result)static voidawait(java.lang.String reason, java.util.function.Supplier<java.lang.Boolean> unblockCondition)Block current thread until unblockCondition is evaluated to true.static voidexit()Stop executing all workflow threads and putsDeterministicRunnerinto closed state.voidexitThread()longgetId()java.lang.StringgetName()intgetPriority()io.temporal.internal.sync.DeterministicRunnerImplgetRunner()java.lang.StringgetStackTrace()<T> java.util.Optional<java.util.Optional<T>>getThreadLocal(WorkflowThreadLocalInternal<T> key)java.lang.ThrowablegetUnhandledException()io.temporal.internal.sync.SyncWorkflowContextgetWorkflowContext()io.temporal.internal.sync.WorkflowThreadContextgetWorkflowThreadContext()booleanisDone()booleanisStarted()NonIdempotentHandlelockDeadlockDetector()Disables deadlock detector on this threadstatic WorkflowThreadnewThread(java.lang.Runnable runnable, boolean detached)Creates a new thread instance.static WorkflowThreadnewThread(java.lang.Runnable runnable, boolean detached, java.lang.String name)booleanrunUntilBlocked(long deadlockDetectionTimeoutMs)voidsetName(java.lang.String name)<T> voidsetThreadLocal(WorkflowThreadLocalInternal<T> key, T value)voidstart()java.util.concurrent.Future<?>stopNow()voidyield(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 DestroyWorkflowThreadErrorBlock 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).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.
-
lockDeadlockDetector
NonIdempotentHandle lockDeadlockDetector()
Disables deadlock detector on this thread- Returns:
- a handle that must be used to unlock the deadlock detector back
-
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 DestroyWorkflowThreadError- Throws:
DestroyWorkflowThreadError
-
exit
static void exit()
Stop executing all workflow threads and putsDeterministicRunnerinto closed state. To be called only from a workflow thread.
-
exitThread
void exitThread()
-
setThreadLocal
<T> void setThreadLocal(WorkflowThreadLocalInternal<T> key, T value)
-
getThreadLocal
<T> java.util.Optional<java.util.Optional<T>> getThreadLocal(WorkflowThreadLocalInternal<T> key)
-
getWorkflowThreadContext
io.temporal.internal.sync.WorkflowThreadContext getWorkflowThreadContext()
-
-