![]() | ![]() | ![]() | Schedulers | Contents | Index |
A Reactor (or an instance of a subtype) is executed using a
scheduler. The Reactor trait introduces the
scheduler member which returns the scheduler used to execute
its instances:
def scheduler: IScheduler
The run-time system executes actors by submitting tasks to the
scheduler using one of the execute methods defined in the
IScheduler trait. Most of the trait's other methods are only
relevant when implementing a new scheduler from scratch, which is
rarely necessary.
The default schedulers used to execute instances of Reactor and
Actor detect the situation when all actors have finished their
execution. When this happens, the scheduler shuts itself down
(terminating any threads used by the scheduler). However, some
schedulers, such as the SingleThreadedScheduler (in package
scheduler) have to be shut down explicitly by invoking their
shutdown method.
The easiest way to create a custom scheduler is by extending
SchedulerAdapter, implementing the following abstract member:
def execute(fun: => Unit): Unit
Typically, a concrete implementation would use a thread pool to
execute its fun by-name argument.
![]() | ![]() | ![]() | Schedulers | Contents | Index |