An AsyncScheduler
schedules tasks to be executed asynchronously,
either now or in the future, by means of Javascript's setTimeout
.
Adds trampoline execution capabilities to schedulers, when inherited.
Macros enabling extension methods for Scheduler meant for executing runnables.
Macros enabling extension methods for Scheduler meant for executing runnables.
See:
NOTE: these macros are only defined for Scala < 2.12, because in Scala 2.12 we simply rely on its SAM support.
Helper for building a Scheduler.
Helper for building a Scheduler.
You can inherit from this class and provided a correct scheduleOnce you'll get Scheduler.scheduleWithFixedDelay and Scheduler.scheduleAtFixedRate for free.
A Scheduler type that provides methods for managing termination.
A Scheduler type that provides methods for managing termination.
A SchedulerService
can be shut down, which will cause it to reject
new tasks. The shutdown
method allows previously submitted tasks to
execute before terminating. The awaitTermination
method allows
waiting on all active tasks to finish.
Upon termination, an executor has no tasks actively executing, no tasks
awaiting execution, and no new tasks can be submitted. An unused
SchedulerService
should be shut down to allow reclamation of
its resources.
Runnable that defers the execution of the given reference
with an executeAsync
.
Runnable that defers the execution of the given reference
with an executeAsync
.
This is useful for example when implementing scheduleOnce
,
to introduce a boundary between the scheduling and the execution,
otherwise risk executing the runnable on the wrong thread-pool.
Forces a real asynchronous boundary before executing the given TrampolinedRunnable.
Forces a real asynchronous boundary before executing the given TrampolinedRunnable.
Sometimes you want to execute multiple TrampolinedRunnable instances as a batch, with the functionality provided by schedulers implementing BatchingScheduler, however you might need the very first execution to force an asynchronous boundary.
is the TrampolinedRunnable instance that will get executed and that is supposed to trigger the execution of other trampolined runnables
is the scheduler that gets used for execution.
A scheduler meant for testing purposes.
A scala.concurrentExecutionContext
implementation
that executes runnables immediately, on the current thread,
by means of a trampoline implementation.
A scala.concurrentExecutionContext
implementation
that executes runnables immediately, on the current thread,
by means of a trampoline implementation.
Can be used in some cases to keep the asynchronous execution on the current thread, as an optimization, but be warned, you have to know what you're doing.
The TrampolineExecutionContext
keeps a reference to another
underlying
context, to which it defers for:
Deferring the rest of the queue happens:
underlying
contextblocking
context, the rest of the tasks get re-scheduled for execution
on the underlying
context to prevent any deadlocksThus this implementation is compatible with the
scala.concurrent.BlockContext
, detecting blocking
blocks and
reacting by forking the rest of the queue to prevent deadlocks.
A Scheduler implementation that executes runnables immediately, on the current thread, by means of a trampoline implementation.
A Scheduler implementation that executes runnables immediately, on the current thread, by means of a trampoline implementation.
Can be used in some cases to keep the asynchronous execution on the current thread, as an optimization, but be warned, you have to know what you're doing.
The TrampolineScheduler
keeps a reference to another
underlying
scheduler, to which it defers for:
Deferring the rest of the queue happens:
underlying
schedulerblocking
context, the rest of the tasks get re-scheduled for execution
on the underlying
scheduler to prevent any deadlocksThus this implementation is compatible with the
scala.concurrent.BlockContext
, detecting blocking
blocks and
reacting by forking the rest of the queue to prevent deadlocks.
A marker for callbacks that can be batched and executed locally (on the current thread) by means of a trampoline (if the execution context / scheduler allows it).
A marker for callbacks that can be batched and executed locally (on the current thread) by means of a trampoline (if the execution context / scheduler allows it).
Idea was taken from the scala.concurrent.Future
implementation. Credit should be given where due.
DO NOT use unless you know what you're doing.
Adds trampoline execution capabilities to schedulers, when inherited.
When it receives TrampolinedRunnable instances, it switches to a trampolined mode where all incoming TrampolinedRunnable are executed on the current thread.
This is useful for light-weight callbacks. The idea is borrowed from the implementation of
scala.concurrent.Future
. Currently used as an optimization byTask
in processing its internal callbacks.