Class RootWorkflowThreadImpl
java.lang.Object
io.temporal.internal.sync.RootWorkflowThreadImpl
- All Implemented Interfaces:
WorkflowThread,CancellationScope,Runnable
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddStackTrace(StringBuilder result) voidcancel()Cancels the scope as well as all its childrenvoidCancels the scope as well as all its children.voidevaluateInCoroutineContext(Functions.Proc1<String> function) Evaluates function in the threadContext of the coroutine without unblocking it.voidUse this promise to perform cancellation of async operations.longgetId()getName()intio.temporal.internal.sync.DeterministicRunnerImplRetrieve data from thread locals.io.temporal.internal.sync.SyncWorkflowContextio.temporal.internal.sync.WorkflowThreadContextbooleanIs scope was asked to cancel throughCancellationScope.cancel()or by a parent scope.booleanWhen set to false parent thread cancellation causes this one to get canceled automatically.booleanisDone()booleanDisables deadlock detector on this threadvoidrun()booleanrunUntilBlocked(long deadlockDetectionTimeoutMs) void<T> voidsetThreadLocal(WorkflowThreadLocalInternal<T> key, T value) voidstart()Future<?> stopNow()Interrupt coroutine by throwing DestroyWorkflowThreadError from an await method it is blocked on and return underlying Future to be waited on.void
-
Method Details
-
yield
public void yield(String reason, Supplier<Boolean> unblockCondition) throws DestroyWorkflowThreadError - Specified by:
yieldin interfaceWorkflowThread- Throws:
DestroyWorkflowThreadError
-
run
-
isDetached
public boolean isDetached()Description copied from interface:CancellationScopeWhen set to false parent thread cancellation causes this one to get canceled automatically. When set to true only call toCancellationScope.cancel()leads to this scope cancellation.- Specified by:
isDetachedin interfaceCancellationScope
-
cancel
public void cancel()Description copied from interface:CancellationScopeCancels the scope as well as all its children- Specified by:
cancelin interfaceCancellationScope
-
cancel
Description copied from interface:CancellationScopeCancels the scope as well as all its children.- Specified by:
cancelin interfaceCancellationScope- Parameters:
reason- human-readable reason for the cancellation. Becomes message of the CanceledException thrown.
-
getCancellationReason
- Specified by:
getCancellationReasonin interfaceCancellationScope
-
isCancelRequested
public boolean isCancelRequested()Description copied from interface:CancellationScopeIs scope was asked to cancel throughCancellationScope.cancel()or by a parent scope.- Specified by:
isCancelRequestedin interfaceCancellationScope- Returns:
- whether request is canceled or not.
-
getCancellationRequest
Description copied from interface:CancellationScopeUse this promise to perform cancellation of async operations.- Specified by:
getCancellationRequestin interfaceCancellationScope- Returns:
- promise that becomes ready when scope is canceled. It contains reason value or null if none was provided.
-
start
public void start()- Specified by:
startin interfaceWorkflowThread
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceWorkflowThread
-
getWorkflowThreadContext
public io.temporal.internal.sync.WorkflowThreadContext getWorkflowThreadContext()- Specified by:
getWorkflowThreadContextin interfaceWorkflowThread
-
getRunner
public io.temporal.internal.sync.DeterministicRunnerImpl getRunner()- Specified by:
getRunnerin interfaceWorkflowThread
-
getWorkflowContext
public io.temporal.internal.sync.SyncWorkflowContext getWorkflowContext()- Specified by:
getWorkflowContextin interfaceWorkflowThread
-
setName
- Specified by:
setNamein interfaceWorkflowThread
-
getName
- Specified by:
getNamein interfaceWorkflowThread
-
getId
public long getId()- Specified by:
getIdin interfaceWorkflowThread
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceWorkflowThread
-
runUntilBlocked
public boolean runUntilBlocked(long deadlockDetectionTimeoutMs) - Specified by:
runUntilBlockedin interfaceWorkflowThread- Parameters:
deadlockDetectionTimeoutMs- maximum time in milliseconds the thread can run before calling yield.- Returns:
- true if coroutine made some progress.
-
lockDeadlockDetector
Description copied from interface:WorkflowThreadDisables deadlock detector on this thread- Specified by:
lockDeadlockDetectorin interfaceWorkflowThread- Returns:
- a handle that must be used to unlock the deadlock detector back
-
isDone
public boolean isDone()- Specified by:
isDonein interfaceWorkflowThread
-
getUnhandledException
- Specified by:
getUnhandledExceptionin interfaceWorkflowThread
-
evaluateInCoroutineContext
Evaluates function in the threadContext of the coroutine without unblocking it. Used to get current coroutine status, like stack trace.- Parameters:
function- Parameter is reason for current goroutine blockage.
-
stopNow
Interrupt coroutine by throwing DestroyWorkflowThreadError from an await method it is blocked on and return underlying Future to be waited on.- Specified by:
stopNowin interfaceWorkflowThread
-
addStackTrace
- Specified by:
addStackTracein interfaceWorkflowThread
-
exitThread
public void exitThread()- Specified by:
exitThreadin interfaceWorkflowThread
-
setThreadLocal
- Specified by:
setThreadLocalin interfaceWorkflowThread
-
getThreadLocal
Retrieve data from thread locals. Returns 1. not found (an empty Optional) 2. found but null (an Optional of an empty Optional) 3. found and non-null (an Optional of an Optional of a value). The type nesting is because Java Optionals cannot understand "Some null" vs "None", which is exactly what we need here.- Specified by:
getThreadLocalin interfaceWorkflowThread- Type Parameters:
T-- Parameters:
key-- Returns:
- one of three cases
-
getStackTrace
- Specified by:
getStackTracein interfaceWorkflowThread- Returns:
- stack trace of the coroutine thread
-