Package net.officefloor.web.executive
Class WebThreadAffinityExecutive
java.lang.Object
net.officefloor.web.executive.WebThreadAffinityExecutive
- All Implemented Interfaces:
BackgroundScheduler,ExecutionStrategy,Executive,TeamOversight
public class WebThreadAffinityExecutive
extends Object
implements Executive, BackgroundScheduler, ExecutionStrategy, TeamOversight
- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionWebThreadAffinityExecutive(CpuCore[] cpuCores, ExecutiveSourceContext context) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptioncreateExecutor(ProcessIdentifier processIdentifier) createProcessIdentifier(ExecutiveOfficeContext officeContext) Creates a newProcessIdentifier.createTeam(ExecutiveContext context) Creates theTeam.Obtains theExecutionStrategystrategies.Obtains the name of theExecutionStrategy.Obtains theTeamOversight.<T extends Throwable>
ProcessManagermanageExecution(Execution<T> execution) Manages theExecution.voidSchedules theRunnableto be executed after the delay.voidschedule(ProcessIdentifier processIdentifier, long delay, Runnable runnable) Schedules theRunnableto execute so many milliseconds in the future.voidstartManaging(ExecutiveStartContext context) Starts managing theOfficeFloor.voidStops managing theOfficeFloor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.officefloor.frame.api.executive.Executive
createThread, getOfficeManager, processComplete
-
Constructor Details
-
WebThreadAffinityExecutive
Instantiate.- Parameters:
cpuCores-CpuCoreinstances.context-ExecutiveSourceContext.
-
-
Method Details
-
getExcutionStrategies
Description copied from interface:ExecutiveObtains theExecutionStrategystrategies.- Specified by:
getExcutionStrategiesin interfaceExecutive- Returns:
ExecutionStrategyinstances.
-
getTeamOversight
Description copied from interface:ExecutiveObtains theTeamOversight.- Specified by:
getTeamOversightin interfaceExecutive- Returns:
TeamOversight.
-
startManaging
Description copied from interface:ExecutiveStarts managing theOfficeFloor.- Specified by:
startManagingin interfaceExecutive- Parameters:
context-ExecutiveStartContext.- Throws:
Exception- If fails to start managing.
-
manageExecution
Description copied from interface:ExecutiveManages the
Execution.The
Thread.currentThread()will provide the inboundThread.- Specified by:
manageExecutionin interfaceExecutive- Type Parameters:
T- Type ofThrowablethrown.- Parameters:
execution-Executionto be undertaken.- Returns:
ProcessManagerfor theProcessState.- Throws:
T- Propagation of failure fromExecution.
-
createProcessIdentifier
Description copied from interface:ExecutiveCreates a newProcessIdentifier.- Specified by:
createProcessIdentifierin interfaceExecutive- Parameters:
officeContext-ExecutiveOfficeContext.- Returns:
- New
ProcessIdentifier.
-
createExecutor
Description copied from interface:ExecutiveCreates an
ExecutorthatMUSTexecute theRunnablein a differentThreadto the caller.This is used in various places within
OfficeFloor:- By
ManagedFunctionin executingRunnablein anotherThread - To avoid stack over flow issues, the stack call chain is broken by
invoking further
FunctionStatedelegation in anotherThread. This allows further depth to a thread stack than offered by a singleThread.
- Specified by:
createExecutorin interfaceExecutive- Parameters:
processIdentifier-ProcessIdentifierofProcessStaterequiring theExecutor.- Returns:
Executorthat will executeRunnableinstances in a differentThreadto caller.
- By
-
schedule
Description copied from interface:ExecutiveSchedules the
Runnableto execute so many milliseconds in the future.Note that the
Executivemay determine theProcessStatecomplete and not execute theRunnable.- Specified by:
schedulein interfaceExecutive- Parameters:
processIdentifier-ProcessIdentifierof theProcessStaterequiring the scheduled execution.delay- Delay in milliseconds to execute theRunnable.runnable-Runnableto execute.
-
stopManaging
Description copied from interface:ExecutiveStops managing theOfficeFloor.- Specified by:
stopManagingin interfaceExecutive- Throws:
Exception- If fails to stop managing.
-
schedule
Description copied from interface:BackgroundSchedulerSchedules theRunnableto be executed after the delay.- Specified by:
schedulein interfaceBackgroundScheduler- Parameters:
delay- Delay in milliseconds.runnable-Runnable.
-
getExecutionStrategyName
Description copied from interface:ExecutionStrategyObtains the name of theExecutionStrategy.- Specified by:
getExecutionStrategyNamein interfaceExecutionStrategy- Returns:
- Name of the
ExecutionStrategy.
-
getThreadFactories
Description copied from interface:ExecutionStrategy- Specified by:
getThreadFactoriesin interfaceExecutionStrategy- Returns:
ThreadFactoryinstances.
-
createTeam
Description copied from interface:TeamOversightCreates the
Team.This is expected to delegate to the
TeamSourceto create theTeam. However, theExecutivemay decide to wrap theTeamor provide multipleTeaminstances with assigning algorithm (such as taking advantage ofThreadaffinity). The choice is, however, ultimately left to theExecutiveto manage theTeaminstances.- Specified by:
createTeamin interfaceTeamOversight- Parameters:
context-ExecutiveContext.- Returns:
Team.- Throws:
Exception- If fails to configure theTeamSource.
-