Packages

abstract class ExecutorScheduler extends SchedulerService with ReferenceScheduler with BatchingScheduler

An ExecutorScheduler is a class for building a SchedulerService out of a Java ExecutorService.

Source
ExecutorScheduler.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ExecutorScheduler
  2. BatchingScheduler
  3. ReferenceScheduler
  4. SchedulerService
  5. Scheduler
  6. Executor
  7. UncaughtExceptionReporter
  8. Serializable
  9. Serializable
  10. ExecutionContext
  11. AnyRef
  12. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ExecutorScheduler(e: ExecutorService, r: UncaughtExceptionReporter)

Abstract Value Members

  1. abstract def executionModel: execution.ExecutionModel

    The ExecutionModel is a specification of how run-loops and producers should behave in regards to executing tasks either synchronously or asynchronously.

    The ExecutionModel is a specification of how run-loops and producers should behave in regards to executing tasks either synchronously or asynchronously.

    Definition Classes
    Scheduler
  2. abstract def scheduleOnce(initialDelay: Long, unit: TimeUnit, r: Runnable): Cancelable

    Schedules a task to run in the future, after initialDelay.

    Schedules a task to run in the future, after initialDelay.

    For example the following schedules a message to be printed to standard output after 5 minutes:

    val task = scheduler.scheduleOnce(5, TimeUnit.MINUTES, new Runnable {
      def run() = print("Hello, world!")
    })
    
    // later if you change your mind ...
    task.cancel()
    initialDelay

    is the time to wait until the execution happens

    unit

    is the time unit used for initialDelay

    r

    is the callback to be executed

    returns

    a Cancelable that can be used to cancel the created task before execution.

    Definition Classes
    Scheduler

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final def awaitTermination(timeout: Long, unit: TimeUnit, awaitOn: Scheduler): Future[Boolean]

    Returns a Future that will be complete when all tasks have completed execution after a shutdown request, or the timeout occurs, or the thread awaiting the shutdown is interrupted, whichever happens first.

    Returns a Future that will be complete when all tasks have completed execution after a shutdown request, or the timeout occurs, or the thread awaiting the shutdown is interrupted, whichever happens first.

    NOTE that this method does not block the current thread, unlike the similarly named method in Java's ExecutionService. This is because Monix has a strict non-blocking policy, due to the fact that other platforms like Javascript cannot block threads.

    Because of the non-blocking requirement, this method returns a Future result. And on top of the JVM in order to block on such a result, you can just use Scala's Await.result:

    import scala.concurrent.Await
    import scala.concurrent.duration._
    import monix.execution.Scheduler.global
    
    val wasTerminated =
      Await.result(service.awaitTermination(30.seconds, global), Duration.Inf)

    Given the asynchronous execution requirement, the awaitOn parameter is a Scheduler that's going to be used for terminating this service and completing our Future. Obviously we cannot reuse this service for awaiting on termination, but Monix's Scheduler.global can always be used for this.

    timeout

    the maximum time to wait

    unit

    the time unit of the timeout argument

    awaitOn

    the Scheduler used for awaiting the shutdown

    returns

    a Future signaling true if this scheduler terminated or false if the timeout elapsed before termination

    Definition Classes
    ExecutorSchedulerSchedulerService
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def currentTimeMillis(): Long

    Returns the current time in milliseconds.

    Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

    It's the equivalent of System.currentTimeMillis(). When wanting to measure time, do not use System.currentTimeMillis() directly, prefer this method instead, because then it can be mocked for testing purposes (see for example TestScheduler)

    Definition Classes
    ReferenceSchedulerScheduler
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. final def execute(runnable: Runnable): Unit

    Schedules the given command for execution at some time in the future.

    Schedules the given command for execution at some time in the future.

    The command may execute in a new thread, in a pooled thread, in the calling thread, basically at the discretion of the Scheduler implementation.

    Definition Classes
    BatchingSchedulerScheduler → Executor → ExecutionContext
  11. final def executeAsync(r: Runnable): Unit
    Attributes
    protected
    Definition Classes
    ExecutorSchedulerBatchingScheduler
  12. def executor: ExecutorService

    Returns the underlying ExecutorService reference.

  13. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def isShutdown: Boolean

    Returns true if this scheduler has been shut down.

    Returns true if this scheduler has been shut down.

    Definition Classes
    ExecutorSchedulerSchedulerService
  18. final def isTerminated: Boolean

    Returns true if all tasks have completed following shut down.

    Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless shutdown was called first.

    Definition Classes
    ExecutorSchedulerSchedulerService
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  22. final def reportFailure(t: Throwable): Unit

    Reports that an asynchronous computation failed.

    Reports that an asynchronous computation failed.

    Definition Classes
    ExecutorSchedulerSchedulerUncaughtExceptionReporter → ExecutionContext
  23. def scheduleAtFixedRate(initialDelay: Long, period: Long, unit: TimeUnit, r: Runnable): Cancelable

    Schedules a periodic task that becomes enabled first after the given initial delay, and subsequently with the given period.

    Schedules a periodic task that becomes enabled first after the given initial delay, and subsequently with the given period. Executions will commence after initialDelay then initialDelay + period, then initialDelay + 2 * period and so on.

    If any execution of the task encounters an exception, subsequent executions are suppressed. Otherwise, the task will only terminate via cancellation or termination of the scheduler. If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

    For example the following schedules a message to be printed to standard output approximately every 10 seconds with an initial delay of 5 seconds:

    val task = scheduler.scheduleAtFixedRate(5, 10, TimeUnit.SECONDS, new Runnable {
      def run() = print("Repeated message")
    })
    
    // later if you change your mind ...
    task.cancel()
    initialDelay

    is the time to wait until the first execution happens

    period

    is the time to wait between 2 successive executions of the task

    unit

    is the time unit used for the initialDelay and the period parameters

    r

    is the callback to be executed

    returns

    a cancelable that can be used to cancel the execution of this repeated task at any time.

    Definition Classes
    ReferenceSchedulerScheduler
  24. def scheduleWithFixedDelay(initialDelay: Long, delay: Long, unit: TimeUnit, r: Runnable): Cancelable

    Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.

    Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.

    For example the following schedules a message to be printed to standard output every 10 seconds with an initial delay of 5 seconds:

    val task = s.scheduleWithFixedDelay(5, 10, TimeUnit.SECONDS, new Runnable {
      def run() = print("Repeated message")
    })
    
    // later if you change your mind ...
    task.cancel()
    initialDelay

    is the time to wait until the first execution happens

    delay

    is the time to wait between 2 successive executions of the task

    unit

    is the time unit used for the initialDelay and the delay parameters

    r

    is the callback to be executed

    returns

    a cancelable that can be used to cancel the execution of this repeated task at any time.

    Definition Classes
    ReferenceSchedulerScheduler
  25. final def shutdown(): Unit

    Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.

    Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.

    This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

    Definition Classes
    ExecutorSchedulerSchedulerService
  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def toString(): String
    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def withExecutionModel(em: execution.ExecutionModel): SchedulerService

    Given a function that will receive the underlying ExecutionModel, returns a new Scheduler reference, based on the source, that exposes the transformed ExecutionModel when queried by means of the executionModel property.

    Given a function that will receive the underlying ExecutionModel, returns a new Scheduler reference, based on the source, that exposes the transformed ExecutionModel when queried by means of the executionModel property.

    This method enables reusing global scheduler references in a local scope, but with a slightly modified execution model to inject.

    The contract of this method (things you can rely on):

    1. the source Scheduler must not be modified in any way
    2. the implementation should wrap the source efficiently, such that the result mirrors the source Scheduler in every way except for the execution model

    Sample:

    import monix.execution.Scheduler.global
    
    implicit val scheduler = {
      val em = global.executionModel
      global.withExecutionModel(em.withAutoCancelableLoops(true))
    }
    Definition Classes
    ExecutorSchedulerReferenceSchedulerSchedulerServiceScheduler

Deprecated Value Members

  1. def prepare(): ExecutionContext
    Definition Classes
    ExecutionContext
    Annotations
    @deprecated
    Deprecated

    (Since version 2.12.0) preparation of ExecutionContexts will be removed

Inherited from BatchingScheduler

Inherited from ReferenceScheduler

Inherited from SchedulerService

Inherited from Scheduler

Inherited from Executor

Inherited from UncaughtExceptionReporter

Inherited from Serializable

Inherited from Serializable

Inherited from ExecutionContext

Inherited from AnyRef

Inherited from Any

Ungrouped