Interface ThreadState
-
- All Superinterfaces:
LinkedListSetEntry<ThreadState,ProcessState>
- All Known Implementing Classes:
ThreadStateImpl
public interface ThreadState extends LinkedListSetEntry<ThreadState,ProcessState>
State of a thread within the
ProcessState.May be used as a
LinkedListSetEntryin a list ofThreadStateinstances for aProcessState.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FlowcreateFlow(FlowCompletion flowCompletion, EscalationCompletion escalationCompletion)Creates aFlowcontained in thisThreadState.FunctionStateflowComplete(Flow flow, java.lang.Throwable flowEscalation, EscalationCompletion completion)Flags that the inputFlowhas completed.TeamManagementgetBreakChainTeamManagement()Obtains theTeamManagementto breakFunctionStatecall chains.GovernanceContainer<?>getGovernanceContainer(int index)Obtains theGovernanceContainerfor the input index.ManagedObjectContainergetManagedObjectContainer(int index)Obtains theManagedObjectContainerfor the input index.intgetMaximumFunctionChainLength()Obtains the maximumFunctionStatechain length for thisThreadState.ProcessStategetProcessState()Obtains theProcessStateof the process containing thisThreadState.FunctionStatehandleEscalation(java.lang.Throwable escalation, EscalationCompletion completion)booleanisAttachedToThread()Indicates if thisThreadStateis attached to the currentThread.booleanisGovernanceActive(int index)Indicates if theGovernanceis active.booleanisThreadStateSafe()Indicates if changes to theThreadStateare safe on the currentThread.voidprofile(ManagedFunctionLogicMetaData functionMetaData)Profiles thatManagedObjectContaineris being executed.FunctionStateregisterThreadProfiler()Obtains theFunctionStateto register theThreadProfiler.<R,T extends java.lang.Throwable>
RrunProcessSafeOperation(ProcessSafeOperation<R,T> operation)Runs theProcessSafeOperation.<R,T extends java.lang.Throwable>
RrunThreadSafeOperation(ThreadSafeOperation<R,T> operation)Run theThreadSafeOperation.FunctionStatethen(FunctionState function, FunctionState thenFunction)CreatesFunctionStateto execute the chain of the firstFunctionStatebefore moving onto execute the chain of the secondFunctionState.-
Methods inherited from interface net.officefloor.frame.internal.structure.LinkedListSetEntry
getLinkedListSetOwner, getNext, getPrev, setNext, setPrev
-
-
-
-
Method Detail
-
isAttachedToThread
boolean isAttachedToThread()
Indicates if thisThreadStateis attached to the currentThread.- Returns:
trueifThreadStateis attached to the currentThread.
-
isThreadStateSafe
boolean isThreadStateSafe()
Indicates if changes to theThreadStateare safe on the currentThread.- Returns:
trueshould changes to theThreadStatebe safe on the currentThread.
-
then
FunctionState then(FunctionState function, FunctionState thenFunction)
CreatesFunctionStateto execute the chain of the firstFunctionStatebefore moving onto execute the chain of the secondFunctionState.- Parameters:
function- Head of initialFunctionStatechain to complete.thenFunction- Head of the secondFunctionStatechain to then complete next.- Returns:
FunctionStateto execute the chains one after another.
-
getMaximumFunctionChainLength
int getMaximumFunctionChainLength()
Obtains the maximum
FunctionStatechain length for thisThreadState.Once the
FunctionStatechain has reached this length, it will be broken. (spawned in anotherThread). This avoidsStackOverflowErrorissues inFunctionStatechain being too large.- Returns:
- Maximum
FunctionStatechain length for thisThreadState.
-
getBreakChainTeamManagement
TeamManagement getBreakChainTeamManagement()
Obtains theTeamManagementto breakFunctionStatecall chains.- Returns:
TeamManagementfor an activeTeam. An activeTeamcontainsThreadinstances that will execute theJobwith a differentThreadstack.
-
runThreadSafeOperation
<R,T extends java.lang.Throwable> R runThreadSafeOperation(ThreadSafeOperation<R,T> operation) throws T extends java.lang.Throwable
Run the
ThreadSafeOperation.Initially locks are not taken to make the main
ThreadStatesafe. This ensures theThreadSafeOperationis run under critical section of thisThreadState.- Type Parameters:
R- Return type fromThreadSafeOperation.T- PossibleEscalationfromThreadSafeOperation.- Parameters:
operation-ThreadSafeOperation.- Returns:
- Optional return value from
ThreadSafeOperation. - Throws:
T- OptionalThrowablefromThreadSafeOperation.T extends java.lang.Throwable
-
runProcessSafeOperation
<R,T extends java.lang.Throwable> R runProcessSafeOperation(ProcessSafeOperation<R,T> operation) throws T extends java.lang.Throwable
Runs theProcessSafeOperation.- Type Parameters:
R- Return type fromProcessSafeOperation.T- PossibleEscalationfromProcessSafeOperation.- Parameters:
operation-ProcessSafeOperation.- Returns:
- Optional return value from
ProcessSafeOperation. - Throws:
T- OptionalThrowablefromProcessSafeOperation.T extends java.lang.Throwable
-
createFlow
Flow createFlow(FlowCompletion flowCompletion, EscalationCompletion escalationCompletion)
Creates aFlowcontained in thisThreadState.- Parameters:
flowCompletion- OptionalFlowCompletionto handle completion of theFlow. May benull.escalationCompletion- OptionalEscalationCompletionto handle completion ofFlowand notifyEscalationhandling complete. May benull.- Returns:
- New
Flow.
-
handleEscalation
FunctionState handleEscalation(java.lang.Throwable escalation, EscalationCompletion completion)
- Parameters:
escalation-Escalation.completion- OptionalEscalationCompletionto be notified of completion ofEscalationhandling.- Returns:
FunctionStateto handle theEscalation.
-
flowComplete
FunctionState flowComplete(Flow flow, java.lang.Throwable flowEscalation, EscalationCompletion completion)
Flags that the inputFlowhas completed.- Parameters:
flow-Flowthat has completed.flowEscalation- PossibleEscalationfrom theFlow. May benull.completion-EscalationCompletion. May benull.- Returns:
- Optional
FunctionStateto complete theFlow.
-
getProcessState
ProcessState getProcessState()
Obtains theProcessStateof the process containing thisThreadState.- Returns:
ProcessStateof the process containing thisThreadState.
-
getManagedObjectContainer
ManagedObjectContainer getManagedObjectContainer(int index)
Obtains theManagedObjectContainerfor the input index.- Parameters:
index- Index of theManagedObjectContainerto be returned.- Returns:
ManagedObjectContainerfor the index.
-
getGovernanceContainer
GovernanceContainer<?> getGovernanceContainer(int index)
Obtains theGovernanceContainerfor the input index.- Parameters:
index- Index of theGovernanceContainerto be returned.- Returns:
GovernanceContainerfor the index only if active. If not active will returnnull.
-
isGovernanceActive
boolean isGovernanceActive(int index)
Indicates if the
Governanceis active.This provides a quick check and avoids creation of the
GovernanceContainer.- Parameters:
index- Index of theGovernanceto check active.- Returns:
trueif theGovernanceis active.
-
registerThreadProfiler
FunctionState registerThreadProfiler()
Obtains theFunctionStateto register theThreadProfiler.- Returns:
FunctionStateto register theThreadProfiler. May benullif noThreadProfilerrequired.
-
profile
void profile(ManagedFunctionLogicMetaData functionMetaData)
Profiles thatManagedObjectContaineris being executed.- Parameters:
functionMetaData-ManagedFunctionLogicMetaDataof theManagedFunctionContainerbeing executed.
-
-