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
-
Method Summary
Modifier and TypeMethodDescription<T> Call<T>
Returns aCall
that completes thecont
inuation.protected <T> void
callDidBind
(Cont<?> cont, T value) Introspection callback invoked immediately after a call tocont.bind(value)
returns nominally.protected void
callDidFail
(Cont<?> cont, Throwable error) Introspection callback invoked immediately after a call tocont.bind(T)
fails by throwing anerror
.protected void
callDidTrap
(Cont<?> cont, Throwable error) Introspection callback invoked immediately after a call tocont.trap(error)
returns nominally.protected <T> void
callWillBind
(Cont<T> cont, T value) Introspection callback invoked immediately before a call tocont.bind(value)
.protected void
callWillCue
(Cont<?> cont) Introspection callback invoked before acont
call is cued for execution.protected void
callWillTrap
(Cont<?> cont, Throwable error) Introspection callback invoked immediately before a call tocont.trap(error)
.protected void
Lifecycle callback invoked if thisTheater
encounters an internalerror
.protected void
didStart()
Lifecycle callback invoked before the thread pool starts up.protected void
didStop()
Lifecycle callback invoked after the thread pool shuts down.void
Schedules arunnable
for concurrent execution.final String
name()
final int
final Schedule
schedule()
void
setSchedule
(Schedule schedule) setTimer
(long millis, TimerFunction timer) Schedulestimer
to execute aftermillis
milliseconds have elapsed.void
start()
Ensures that thisTheater
is up and running.void
stop()
Ensures that thisTheater
has been permanently stopped, shutting down the thread pool, if it's currently running.task
(TaskFunction task) Returns an uncuedTaskRef
bound to thetask
, which can later be used to cue thetask
.protected void
taskDidCancel
(TaskFunction task) Introspection callback invoked after a cuedtask
is canceled.protected void
taskDidFail
(TaskFunction task, Throwable error) Introspection callback invoked immediately aftertask.runTask()
fails by throwing anerror
.protected void
taskDidRun
(TaskFunction task) Introspection callback invoked immediately aftertask.runTask()
returns nominally.protected void
taskWillCue
(TaskFunction task) Introspection callback invoked before atask
is cued for execution.protected void
taskWillRun
(TaskFunction task) Introspection callback invoked immediately beforetask.runTask()
is executed.timer
(TimerFunction timer) Returns an unscheduledTimerRef
bound totimer
, which can later be used to scheduletimer
.void
uncaughtException
(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 thisTheater
is up and running.- Specified by:
start
in interfaceMainStage
- Throws:
IllegalStateException
- if thisTheater
has been stopped.
-
stop
public void stop()Ensures that thisTheater
has been permanently stopped, shutting down the thread pool, if it's currently running. Upon return, thisTheater
is guaranteed to be in the stopped state. -
execute
Description copied from interface:Stage
Schedules arunnable
for concurrent execution. -
task
Description copied from interface:Stage
Returns an uncuedTaskRef
bound to thetask
, which can later be used to cue thetask
. -
call
Description copied from interface:Stage
Returns aCall
that completes thecont
inuation. -
timer
Description copied from interface:Schedule
Returns an unscheduledTimerRef
bound totimer
, which can later be used to scheduletimer
. -
setTimer
Description copied from interface:Schedule
Schedulestimer
to execute aftermillis
milliseconds have elapsed. Returns aTimerRef
that 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 thisTheater
encounters an internalerror
. -
taskWillCue
Introspection callback invoked before atask
is cued for execution. -
taskDidCancel
Introspection callback invoked after a cuedtask
is 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 acont
call 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:
uncaughtException
in interfaceThread.UncaughtExceptionHandler
-