Packages

  • package root
    Definition Classes
    root
  • package monix
    Definition Classes
    root
  • package execution
    Definition Classes
    monix
  • package atomic

    A small toolkit of classes that support compare-and-swap semantics for safe mutation of variables.

    A small toolkit of classes that support compare-and-swap semantics for safe mutation of variables.

    On top of the JVM, this means dealing with lock-free thread-safe programming. Also works on top of Javascript, with Scala.js, for API compatibility purposes and because it's a useful way to box a value.

    The backbone of Atomic references is this method:

    def compareAndSet(expect: T, update: T): Boolean

    This method atomically sets a variable to the update value if it currently holds the expect value, reporting true on success or false on failure. The classes in this package also contain methods to get and unconditionally set values.

    Building a reference is easy with the provided constructor, which will automatically return the most specific type needed (in the following sample, that's an AtomicDouble, inheriting from AtomicNumber[A]):

    val atomicNumber = Atomic(12.2)
    
    atomicNumber.incrementAndGet()
    // => 13.2

    These also provide useful helpers for atomically mutating of values (i.e. transform, transformAndGet, getAndTransform, etc...) or of numbers of any kind (incrementAndGet, getAndAdd, etc...).

    Definition Classes
    execution
  • package cancelables

    Cancelables represent asynchronous units of work or other things scheduled for execution and whose execution can be canceled.

    Cancelables represent asynchronous units of work or other things scheduled for execution and whose execution can be canceled.

    One use-case is the scheduling done by monix.execution.Scheduler, in which the scheduling methods return a Cancelable, allowing the canceling of the scheduling.

    Example:

    val s = ConcurrentScheduler()
    val task = s.scheduleRepeated(10.seconds, 50.seconds, {
      doSomething()
    })
    
    // later, cancels the scheduling ...
    task.cancel()
    Definition Classes
    execution
  • package exceptions
    Definition Classes
    execution
  • package misc
    Definition Classes
    execution
  • package rstreams
    Definition Classes
    execution
  • package schedulers
    Definition Classes
    execution
  • AsyncScheduler
  • BatchingScheduler
  • ExecutionModel
  • ReferenceScheduler
  • SchedulerService
  • ShiftedRunnable
  • StartAsyncBatchRunnable
  • TestScheduler
  • TrampolineExecutionContext
  • TrampolineScheduler
  • TrampolinedRunnable
p

monix.execution

schedulers

package schedulers

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. schedulers
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class AsyncScheduler extends ReferenceScheduler with BatchingScheduler

    An AsyncScheduler schedules tasks to be executed asynchronously, either now or in the future, by means of Javascript's setTimeout.

  2. trait BatchingScheduler extends Scheduler

    Adds trampoline execution capabilities to schedulers, when inherited.

    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 by Task in processing its internal callbacks.

  3. trait ReferenceScheduler extends Scheduler

    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.

  4. trait SchedulerService extends Scheduler

    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.

  5. final class ShiftedRunnable extends Runnable

    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.

  6. final case class StartAsyncBatchRunnable(start: TrampolinedRunnable, s: Scheduler) extends Runnable with Serializable with Product

    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.

    start

    is the TrampolinedRunnable instance that will get executed and that is supposed to trigger the execution of other trampolined runnables

    s

    is the scheduler that gets used for execution.

  7. final class TestScheduler extends ReferenceScheduler with BatchingScheduler

    A scheduler meant for testing purposes.

  8. final class TrampolineExecutionContext extends ExecutionContext

    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:

    • reporting errors
    • deferring the rest of the queue in problematic situations

    Deferring the rest of the queue happens:

    • in case we have a runnable throwing an exception, the rest of the tasks get re-scheduled for execution by using the underlying context
    • in case we have a runnable triggering a Scala blocking context, the rest of the tasks get re-scheduled for execution on the underlying context to prevent any deadlocks

    Thus this implementation is compatible with the scala.concurrent.BlockContext, detecting blocking blocks and reacting by forking the rest of the queue to prevent deadlocks.

  9. final class TrampolineScheduler extends Scheduler

    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:

    • reporting errors
    • time-delayed execution
    • deferring the rest of the queue in problematic situations

    Deferring the rest of the queue happens:

    • in case we have a runnable throwing an exception, the rest of the tasks get re-scheduled for execution by using the underlying scheduler
    • in case we have a runnable triggering a Scala blocking context, the rest of the tasks get re-scheduled for execution on the underlying scheduler to prevent any deadlocks

    Thus this implementation is compatible with the scala.concurrent.BlockContext, detecting blocking blocks and reacting by forking the rest of the queue to prevent deadlocks.

  10. abstract class TrampolinedRunnable extends Runnable with OnCompleteRunnable

    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.

  11. type ExecutionModel = execution.ExecutionModel

    Deprecated.

    Deprecated. Moved to monix.execution.ExecutionModel.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.1.3) Moved to monix.execution.ExecutionModel

  12. type LocalBatchingExecutor = BatchingScheduler

    Deprecated.

    Deprecated. Renamed to BatchingScheduler.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.1.0) Renamed to BatchingScheduler

  13. type LocalRunnable = TrampolinedRunnable

    Deprecated.

    Deprecated. Renamed to TrampolinedRunnable.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.1.0) Renamed to TrampolinedRunnable

Deprecated Value Members

  1. object ExecutionModel extends Serializable

    Deprecated.

    Deprecated. Moved to monix.execution.ExecutionModel.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.1.3) Moved to monix.execution.ExecutionModel

Inherited from AnyRef

Inherited from Any

Ungrouped