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 void
exit()
Stop executing all workflow threads and putsDeterministicRunner
into closed state.void
exitThread()
long
getId()
java.lang.String
getName()
int
getPriority()
io.temporal.internal.sync.DeterministicRunnerImpl
getRunner()
java.lang.String
getStackTrace()
<T> java.util.Optional<java.util.Optional<T>>
getThreadLocal(WorkflowThreadLocalInternal<T> key)
java.lang.Throwable
getUnhandledException()
io.temporal.internal.sync.SyncWorkflowContext
getWorkflowContext()
io.temporal.internal.sync.WorkflowThreadContext
getWorkflowThreadContext()
boolean
isDone()
boolean
isStarted()
NonIdempotentHandle
lockDeadlockDetector()
Disables deadlock detector on this threadstatic 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 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).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 putsDeterministicRunner
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> java.util.Optional<java.util.Optional<T>> getThreadLocal(WorkflowThreadLocalInternal<T> key)
-
getWorkflowThreadContext
io.temporal.internal.sync.WorkflowThreadContext getWorkflowThreadContext()
-
-