Class/Object

fs2

Scheduler

Related Docs: object Scheduler | package fs2

Permalink

abstract class Scheduler extends AnyRef

Provides operations based on the passage of cpu time.

Operations on this class generally return streams. Some operations return effectful values instead. These operations are accessed via the .effect method, which returns a projection consisting of operations that return effects.

Source
Scheduler.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Scheduler
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Scheduler()

    Permalink

Abstract Value Members

  1. abstract def scheduleAtFixedRate(period: FiniteDuration)(thunk: ⇒ Unit): () ⇒ Unit

    Permalink

    Evaluates the thunk every period.

    Evaluates the thunk every period. Returns a thunk that when evaluated, cancels the execution.

    Attributes
    protected
  2. abstract def scheduleOnce(delay: FiniteDuration)(thunk: ⇒ Unit): () ⇒ Unit

    Permalink

    Evaluates the thunk after the delay.

    Evaluates the thunk after the delay. Returns a thunk that when evaluated, cancels the execution.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to any2stringadd[Scheduler] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Scheduler, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to ArrowAssoc[Scheduler] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def attempts[F[_], A](s: Stream[F, A], delays: Stream[F, FiniteDuration])(implicit F: Async[F], ec: ExecutionContext): Stream[F, Either[Throwable, A]]

    Permalink

    Retries s on failure, returning a stream of attempts that can be manipulated with standard stream operations such as take, collectFirst and interruptWhen.

    Retries s on failure, returning a stream of attempts that can be manipulated with standard stream operations such as take, collectFirst and interruptWhen.

    Note: The resulting stream does *not* automatically halt at the first successful attempt. Also see retry.

  8. def awakeDelay[F[_]](d: FiniteDuration)(implicit F: Async[F], ec: ExecutionContext): Stream[F, FiniteDuration]

    Permalink

    Light weight alternative to awakeEvery that sleeps for duration d before each pulled element.

  9. def awakeEvery[F[_]](d: FiniteDuration)(implicit F: Effect[F], ec: ExecutionContext): Stream[F, FiniteDuration]

    Permalink

    Discrete stream that every d emits elapsed duration since the start time of stream consumption.

    Discrete stream that every d emits elapsed duration since the start time of stream consumption.

    For example: awakeEvery[IO](5 seconds) will return (approximately) 5s, 10s, 15s, and will lie dormant between emitted values.

    This uses an implicit Scheduler for the timed events, and runs the consumer using the F Effect[F], to allow for the stream to decide whether result shall be run on different thread pool.

    Note: for very small values of d, it is possible that multiple periods elapse and only some of those periods are visible in the stream. This occurs when the scheduler fires faster than periods are able to be published internally, possibly due to an execution context that is slow to evaluate.

    d

    FiniteDuration between emits of the resulting stream

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def debounce[F[_], O](d: FiniteDuration)(implicit F: Effect[F], ec: ExecutionContext): Pipe[F, O, O]

    Permalink

    Debounce the stream with a minimum period of d between each element.

    Debounce the stream with a minimum period of d between each element.

    Example:
    1. scala> import scala.concurrent.duration._, scala.concurrent.ExecutionContext.Implicits.global, cats.effect.IO
      scala> val s2 = Scheduler[IO](1).flatMap { scheduler =>
           |   val s = Stream(1, 2, 3) ++ scheduler.sleep_[IO](500.millis) ++ Stream(4, 5) ++ scheduler.sleep_[IO](10.millis) ++ Stream(6)
           |   s.through(scheduler.debounce(100.milliseconds))
           | }
      scala> s2.compile.toVector.unsafeRunSync
      res0: Vector[Int] = Vector(3, 6)
  12. def delay[F[_], O](s: Stream[F, O], d: FiniteDuration)(implicit F: Async[F], ec: ExecutionContext): Stream[F, O]

    Permalink

    Returns a stream that when run, sleeps for duration d and then pulls from s.

    Returns a stream that when run, sleeps for duration d and then pulls from s.

    Alias for sleep_[F](d) ++ s.

  13. def delayedExecutionContext(delay: FiniteDuration, reporter: (Throwable) ⇒ Unit = ExecutionContext.defaultReporter): ExecutionContext

    Permalink

    Returns an execution context that executes all tasks after a specified delay.

  14. def effect: EffectOps

    Permalink

    Provides scheduler methods that return effectful values instead of streams.

  15. def ensuring(cond: (Scheduler) ⇒ Boolean, msg: ⇒ Any): Scheduler

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to Ensuring[Scheduler] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: (Scheduler) ⇒ Boolean): Scheduler

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to Ensuring[Scheduler] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: Boolean, msg: ⇒ Any): Scheduler

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to Ensuring[Scheduler] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. def ensuring(cond: Boolean): Scheduler

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to Ensuring[Scheduler] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  19. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  21. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. def fixedDelay[F[_]](d: FiniteDuration)(implicit F: Async[F], ec: ExecutionContext): Stream[F, Unit]

    Permalink

    Light weight alternative to fixedRate that sleeps for duration d before each pulled element.

    Light weight alternative to fixedRate that sleeps for duration d before each pulled element.

    Behavior differs from fixedRate because the sleep between elements occurs after the next element is pulled whereas fixedRate awakes every d regardless of when next element is pulled. This difference can roughly be thought of as the difference between scheduleWithFixedDelay and scheduleAtFixedRate in java.util.concurrent.Scheduler.

    Alias for sleep(d).repeat.

  23. def fixedRate[F[_]](d: FiniteDuration)(implicit F: Effect[F], ec: ExecutionContext): Stream[F, Unit]

    Permalink

    Discrete stream that emits a unit every d.

    Discrete stream that emits a unit every d.

    This uses an implicit Scheduler for the timed events, and runs the consumer using the F Effect[F], to allow for the stream to decide whether result shall be run on different thread pool.

    Note: for very small values of d, it is possible that multiple periods elapse and only some of those periods are visible in the stream. This occurs when the scheduler fires faster than periods are able to be published internally, possibly due to an execution context that is slow to evaluate.

    See fixedDelay for an alternative that sleeps d between elements.

    d

    FiniteDuration between emits of the resulting stream

  24. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to StringFormat[Scheduler] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  25. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  26. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  27. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  28. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  29. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  30. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. def retry[F[_], A](fa: F[A], delay: FiniteDuration, nextDelay: (FiniteDuration) ⇒ FiniteDuration, maxRetries: Int, retriable: (Throwable) ⇒ Boolean = internal.NonFatal.apply)(implicit F: Async[F], ec: ExecutionContext): Stream[F, A]

    Permalink

    Retries fa on failure, returning a singleton stream with the result of fa as soon as it succeeds.

    Retries fa on failure, returning a singleton stream with the result of fa as soon as it succeeds.

    delay

    Duration of delay before the first retry

    nextDelay

    Applied to the previous delay to compute the next, e.g. to implement exponential backoff

    maxRetries

    Number of attempts before failing with the latest error, if fa never succeeds

    retriable

    Function to determine whether a failure is retriable or not, defaults to retry every NonFatal. A failed stream is immediately returned when a non-retriable failure is encountered

  32. def sleep[F[_]](d: FiniteDuration)(implicit F: Async[F], ec: ExecutionContext): Stream[F, Unit]

    Permalink

    A single-element Stream that waits for the duration d before emitting unit.

    A single-element Stream that waits for the duration d before emitting unit. This uses the implicit Scheduler to signal duration and avoid blocking on thread. After the signal, the execution continues on the supplied execution context.

  33. def sleep_[F[_]](d: FiniteDuration)(implicit F: Async[F], ec: ExecutionContext): Stream[F, Nothing]

    Permalink

    Alias for sleep(d).drain.

    Alias for sleep(d).drain. Often used in conjunction with ++ (i.e., sleep_(..) ++ s) as a more performant version of sleep(..) >> s.

  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  35. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  36. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. def [B](y: B): (Scheduler, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Scheduler to ArrowAssoc[Scheduler] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Scheduler to any2stringadd[Scheduler]

Inherited by implicit conversion StringFormat from Scheduler to StringFormat[Scheduler]

Inherited by implicit conversion Ensuring from Scheduler to Ensuring[Scheduler]

Inherited by implicit conversion ArrowAssoc from Scheduler to ArrowAssoc[Scheduler]

Ungrouped