final class TrampolineScheduler extends Scheduler
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 
underlyingscheduler - in case we have a runnable triggering a Scala 
blockingcontext, the rest of the tasks get re-scheduled for execution on theunderlyingscheduler 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.
- Self Type
 - TrampolineScheduler
 - Source
 - TrampolineScheduler.scala
 
- Alphabetic
 - By Inheritance
 
- TrampolineScheduler
 - Scheduler
 - Executor
 - UncaughtExceptionReporter
 - Serializable
 - Serializable
 - ExecutionContext
 - AnyRef
 - Any
 
- Hide All
 - Show All
 
- Public
 - All
 
Instance Constructors
- 
      
      
      
        
      
    
      
        
        new
      
      
        TrampolineScheduler(underlying: Scheduler, executionModel: execution.ExecutionModel)
      
      
      
- underlying
 is the
ExecutionContextto which the it defers to in case real asynchronous is needed
 
Value Members
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        !=(arg0: Any): Boolean
      
      
      
- Definition Classes
 - AnyRef → Any
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        ##(): Int
      
      
      
- Definition Classes
 - AnyRef → Any
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        ==(arg0: Any): Boolean
      
      
      
- Definition Classes
 - AnyRef → Any
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        asInstanceOf[T0]: T0
      
      
      
- Definition Classes
 - Any
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        clone(): AnyRef
      
      
      
- Attributes
 - protected[java.lang]
 - Definition Classes
 - AnyRef
 - Annotations
 - @native() @throws( ... )
 
 - 
      
      
      
        
      
    
      
        
        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 useSystem.currentTimeMillis()directly, prefer this method instead, because then it can be mocked for testing purposes (see for example TestScheduler)- Definition Classes
 - TrampolineScheduler → Scheduler
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        eq(arg0: AnyRef): Boolean
      
      
      
- Definition Classes
 - AnyRef
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        equals(arg0: Any): Boolean
      
      
      
- Definition Classes
 - AnyRef → Any
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        execute(runnable: Runnable): Unit
      
      
      
Schedules the given
commandfor execution at some time in the future.Schedules the given
commandfor 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
 - TrampolineScheduler → Scheduler → Executor → ExecutionContext
 
 - 
      
      
      
        
      
    
      
        
        val
      
      
        executionModel: execution.ExecutionModel
      
      
      
- Definition Classes
 - TrampolineScheduler → Scheduler
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        finalize(): Unit
      
      
      
- Attributes
 - protected[java.lang]
 - Definition Classes
 - AnyRef
 - Annotations
 - @throws( classOf[java.lang.Throwable] )
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        getClass(): Class[_]
      
      
      
- Definition Classes
 - AnyRef → Any
 - Annotations
 - @native()
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        hashCode(): Int
      
      
      
- Definition Classes
 - AnyRef → Any
 - Annotations
 - @native()
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        isInstanceOf[T0]: Boolean
      
      
      
- Definition Classes
 - Any
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        ne(arg0: AnyRef): Boolean
      
      
      
- Definition Classes
 - AnyRef
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        notify(): Unit
      
      
      
- Definition Classes
 - AnyRef
 - Annotations
 - @native()
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        notifyAll(): Unit
      
      
      
- Definition Classes
 - AnyRef
 - Annotations
 - @native()
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        reportFailure(t: Throwable): Unit
      
      
      
Reports that an asynchronous computation failed.
Reports that an asynchronous computation failed.
- Definition Classes
 - TrampolineScheduler → Scheduler → UncaughtExceptionReporter → ExecutionContext
 
 - 
      
      
      
        
      
    
      
        
        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
initialDelaytheninitialDelay + period, theninitialDelay + 2 * periodand 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
initialDelayand theperiodparameters- 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
 - TrampolineScheduler → Scheduler
 
 - 
      
      
      
        
      
    
      
        
        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
Cancelablethat can be used to cancel the created task before execution.
- Definition Classes
 - TrampolineScheduler → Scheduler
 
 - 
      
      
      
        
      
    
      
        
        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
initialDelayand thedelayparameters- 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
 - TrampolineScheduler → Scheduler
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        synchronized[T0](arg0: ⇒ T0): T0
      
      
      
- Definition Classes
 - AnyRef
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        toString(): String
      
      
      
- Definition Classes
 - AnyRef → Any
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(): Unit
      
      
      
- Definition Classes
 - AnyRef
 - Annotations
 - @throws( ... )
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(arg0: Long, arg1: Int): Unit
      
      
      
- Definition Classes
 - AnyRef
 - Annotations
 - @throws( ... )
 
 - 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(arg0: Long): Unit
      
      
      
- Definition Classes
 - AnyRef
 - Annotations
 - @native() @throws( ... )
 
 - 
      
      
      
        
      
    
      
        
        def
      
      
        withExecutionModel(em: execution.ExecutionModel): TrampolineScheduler
      
      
      
Given a function that will receive the underlying ExecutionModel, returns a new Scheduler reference, based on the source, that exposes the transformed
ExecutionModelwhen 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
ExecutionModelwhen 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):
- the source 
Schedulermust not be modified in any way - the implementation should wrap the source efficiently, such that the
    result mirrors the source 
Schedulerin 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
 - TrampolineScheduler → Scheduler
 
 - the source 
 
Deprecated Value Members
- 
      
      
      
        
      
    
      
        
        def
      
      
        prepare(): ExecutionContext
      
      
      
- Definition Classes
 - ExecutionContext
 - Annotations
 - @deprecated
 - Deprecated
 (Since version 2.12.0) preparation of ExecutionContexts will be removed
 

This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomictypes, as alternative tojava.util.concurrent.atomicmonix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observablepattern:Observableimplementationsmonix.types implements type-class shims, to be translated to type-classes provided by libraries such as Cats or Scalaz.
monix.cats is the optional integration with the Cats library, providing translations for the types described in
monix.types.monix.scalaz is the optional integration with the Scalaz library, providing translations for the types described in
monix.types.