Evaluates the thunk every period.
Evaluates the thunk every period. Returns a thunk that when evaluated, cancels the execution.
Evaluates the thunk after the delay.
Evaluates the thunk after the delay. Returns a thunk that when evaluated, cancels the execution.
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
.
Light weight alternative to awakeEvery
that sleeps for duration d
before each pulled element.
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.
FiniteDuration between emits of the resulting stream
Debounce the stream with a minimum period of d
between each element.
Debounce the stream with a minimum period of d
between each element.
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)
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
.
Returns an execution context that executes all tasks after a specified delay.
Provides scheduler methods that return effectful values instead of streams.
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
.
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.
FiniteDuration between emits of the resulting stream
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.
Duration of delay before the first retry
Applied to the previous delay to compute the next, e.g. to implement exponential backoff
Number of attempts before failing with the
latest error, if fa
never succeeds
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
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.
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
.
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.