java.lang.Object
swim.concurrent.Theater
- All Implemented Interfaces:
Thread.UncaughtExceptionHandler,Executor,MainStage,Schedule,Stage
Stage that executes timers, tasks, and continuations on a
ForkJoinPool.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Call<T>Returns aCallthat completes thecontinuation.protected <T> voidcallDidBind(Cont<?> cont, T value) Introspection callback invoked immediately after a call tocont.bind(value)returns nominally.protected voidcallDidFail(Cont<?> cont, Throwable error) Introspection callback invoked immediately after a call tocont.bind(T)fails by throwing anerror.protected voidcallDidTrap(Cont<?> cont, Throwable error) Introspection callback invoked immediately after a call tocont.trap(error)returns nominally.protected <T> voidcallWillBind(Cont<T> cont, T value) Introspection callback invoked immediately before a call tocont.bind(value).protected voidcallWillCue(Cont<?> cont) Introspection callback invoked before acontcall is cued for execution.protected voidcallWillTrap(Cont<?> cont, Throwable error) Introspection callback invoked immediately before a call tocont.trap(error).protected voidLifecycle callback invoked if thisTheaterencounters an internalerror.protected voiddidStart()Lifecycle callback invoked before the thread pool starts up.protected voiddidStop()Lifecycle callback invoked after the thread pool shuts down.voidSchedules arunnablefor concurrent execution.final Stringname()final intfinal Scheduleschedule()voidsetSchedule(Schedule schedule) setTimer(long millis, TimerFunction timer) Schedulestimerto execute aftermillismilliseconds have elapsed.voidstart()Ensures that thisTheateris up and running.voidstop()Ensures that thisTheaterhas been permanently stopped, shutting down the thread pool, if it's currently running.task(TaskFunction task) Returns an uncuedTaskRefbound to thetask, which can later be used to cue thetask.protected voidtaskDidCancel(TaskFunction task) Introspection callback invoked after a cuedtaskis canceled.protected voidtaskDidFail(TaskFunction task, Throwable error) Introspection callback invoked immediately aftertask.runTask()fails by throwing anerror.protected voidtaskDidRun(TaskFunction task) Introspection callback invoked immediately aftertask.runTask()returns nominally.protected voidtaskWillCue(TaskFunction task) Introspection callback invoked before ataskis cued for execution.protected voidtaskWillRun(TaskFunction task) Introspection callback invoked immediately beforetask.runTask()is executed.timer(TimerFunction timer) Returns an unscheduledTimerRefbound totimer, which can later be used to scheduletimer.voiduncaughtException(Thread thead, Throwable error)
-
Constructor Details
-
Theater
-
Theater
-
Theater
-
Theater
-
Theater
-
Theater
-
Theater
public Theater(int parallelism) -
Theater
-
Theater
public Theater()
-
-
Method Details
-
name
-
parallelism
public final int parallelism() -
schedule
-
setSchedule
-
start
public void start()Ensures that thisTheateris up and running.- Specified by:
startin interfaceMainStage- Throws:
IllegalStateException- if thisTheaterhas been stopped.
-
stop
public void stop()Ensures that thisTheaterhas been permanently stopped, shutting down the thread pool, if it's currently running. Upon return, thisTheateris guaranteed to be in the stopped state. -
execute
Description copied from interface:StageSchedules arunnablefor concurrent execution. -
task
Description copied from interface:StageReturns an uncuedTaskRefbound to thetask, which can later be used to cue thetask. -
call
Description copied from interface:StageReturns aCallthat completes thecontinuation. -
timer
Description copied from interface:ScheduleReturns an unscheduledTimerRefbound totimer, which can later be used to scheduletimer. -
setTimer
Description copied from interface:ScheduleSchedulestimerto execute aftermillismilliseconds have elapsed. Returns aTimerRefthat can be used to check the status of, reschedule, and canceltimer. -
didStart
protected void didStart()Lifecycle callback invoked before the thread pool starts up. -
didStop
protected void didStop()Lifecycle callback invoked after the thread pool shuts down. -
didFail
Lifecycle callback invoked if thisTheaterencounters an internalerror. -
taskWillCue
Introspection callback invoked before ataskis cued for execution. -
taskDidCancel
Introspection callback invoked after a cuedtaskis canceled. -
taskWillRun
Introspection callback invoked immediately beforetask.runTask()is executed. -
taskDidRun
Introspection callback invoked immediately aftertask.runTask()returns nominally. -
taskDidFail
Introspection callback invoked immediately aftertask.runTask()fails by throwing anerror. -
callWillCue
Introspection callback invoked before acontcall is cued for execution. -
callWillBind
Introspection callback invoked immediately before a call tocont.bind(value). -
callDidBind
Introspection callback invoked immediately after a call tocont.bind(value)returns nominally. -
callWillTrap
Introspection callback invoked immediately before a call tocont.trap(error). -
callDidTrap
Introspection callback invoked immediately after a call tocont.trap(error)returns nominally. -
callDidFail
Introspection callback invoked immediately after a call tocont.bind(T)fails by throwing anerror. -
uncaughtException
- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler
-