Class WebThreadAffinityExecutive
- java.lang.Object
-
- net.officefloor.web.executive.WebThreadAffinityExecutive
-
- All Implemented Interfaces:
BackgroundScheduler,ExecutionStrategy,Executive,TeamOversight
public class WebThreadAffinityExecutive extends java.lang.Object implements Executive, BackgroundScheduler, ExecutionStrategy, TeamOversight
WebThreadaffinityExecutive.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description WebThreadAffinityExecutive(CpuCore[] cpuCores, ExecutiveSourceContext context)Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.ExecutorcreateExecutor(ProcessIdentifier processIdentifier)Creates anExecutorthat MUST execute theRunnablein a differentThreadto the caller.ProcessIdentifiercreateProcessIdentifier(ExecutiveOfficeContext officeContext)Creates a newProcessIdentifier.TeamcreateTeam(ExecutiveContext context)Creates theTeam.ExecutionStrategy[]getExcutionStrategies()Obtains theExecutionStrategystrategies.java.lang.StringgetExecutionStrategyName()Obtains the name of theExecutionStrategy.TeamOversightgetTeamOversight()Obtains theTeamOversight.java.util.concurrent.ThreadFactory[]getThreadFactories()<T extends java.lang.Throwable>
ProcessManagermanageExecution(Execution<T> execution)Manages theExecution.voidschedule(long delay, java.lang.Runnable runnable)Schedules theRunnableto be executed after the delay.voidschedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)Schedules theRunnableto execute so many milliseconds in the future.voidstartManaging(ExecutiveStartContext context)Starts managing theOfficeFloor.voidstopManaging()Stops managing theOfficeFloor.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.officefloor.frame.api.executive.Executive
createThread, getOfficeManager, processComplete
-
-
-
-
Constructor Detail
-
WebThreadAffinityExecutive
public WebThreadAffinityExecutive(CpuCore[] cpuCores, ExecutiveSourceContext context)
Instantiate.- Parameters:
cpuCores-CpuCoreinstances.context-ExecutiveSourceContext.
-
-
Method Detail
-
getExcutionStrategies
public ExecutionStrategy[] getExcutionStrategies()
Description copied from interface:ExecutiveObtains theExecutionStrategystrategies.- Specified by:
getExcutionStrategiesin interfaceExecutive- Returns:
ExecutionStrategyinstances.
-
getTeamOversight
public TeamOversight getTeamOversight()
Description copied from interface:ExecutiveObtains theTeamOversight.- Specified by:
getTeamOversightin interfaceExecutive- Returns:
TeamOversight.
-
startManaging
public void startManaging(ExecutiveStartContext context) throws java.lang.Exception
Description copied from interface:ExecutiveStarts managing theOfficeFloor.- Specified by:
startManagingin interfaceExecutive- Parameters:
context-ExecutiveStartContext.- Throws:
java.lang.Exception- If fails to start managing.
-
manageExecution
public <T extends java.lang.Throwable> ProcessManager manageExecution(Execution<T> execution) throws T extends java.lang.Throwable
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.T extends java.lang.Throwable
-
createProcessIdentifier
public ProcessIdentifier createProcessIdentifier(ExecutiveOfficeContext officeContext)
Description copied from interface:ExecutiveCreates a newProcessIdentifier.- Specified by:
createProcessIdentifierin interfaceExecutive- Parameters:
officeContext-ExecutiveOfficeContext.- Returns:
- New
ProcessIdentifier.
-
createExecutor
public java.util.concurrent.Executor createExecutor(ProcessIdentifier processIdentifier)
Description copied from interface:ExecutiveCreates an
Executorthat MUST execute 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
public void schedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)
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
public void stopManaging() throws java.lang.ExceptionDescription copied from interface:ExecutiveStops managing theOfficeFloor.- Specified by:
stopManagingin interfaceExecutive- Throws:
java.lang.Exception- If fails to stop managing.
-
schedule
public void schedule(long delay, java.lang.Runnable runnable)Description copied from interface:BackgroundSchedulerSchedules theRunnableto be executed after the delay.- Specified by:
schedulein interfaceBackgroundScheduler- Parameters:
delay- Delay in milliseconds.runnable-Runnable.
-
getExecutionStrategyName
public java.lang.String getExecutionStrategyName()
Description copied from interface:ExecutionStrategyObtains the name of theExecutionStrategy.- Specified by:
getExecutionStrategyNamein interfaceExecutionStrategy- Returns:
- Name of the
ExecutionStrategy.
-
getThreadFactories
public java.util.concurrent.ThreadFactory[] getThreadFactories()
Description copied from interface:ExecutionStrategy- Specified by:
getThreadFactoriesin interfaceExecutionStrategy- Returns:
ThreadFactoryinstances.
-
createTeam
public Team createTeam(ExecutiveContext context) throws java.lang.Exception
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:
java.lang.Exception- If fails to configure theTeamSource.
-
-