trait Async[F[_]] extends AsyncPlatform[F] with Sync[F] with Temporal[F]
A typeclass that encodes the notion of suspending asynchronous side effects in the F[_]
context
An asynchronous task is one whose results are computed somewhere else (eg by a scala.concurrent.Future running on some other threadpool). We await the results of that execution by giving it a callback to be invoked with the result.
That computation may fail hence the callback is of type Either[Throwable, A] => ()
. This
awaiting is semantic only - no threads are blocked, the current fiber is simply descheduled
until the callback completes.
This leads us directly to the simplest asynchronous FFI
def async_[A](k: (Either[Throwable, A] => Unit) => Unit): F[A]
async(k)
is semantically blocked until the callback is invoked.
async_
is somewhat constrained however. We can't perform any F[_]
effects in the process
of registering the callback and we also can't register a finalizer to eg cancel the
asynchronous task in the event that the fiber running async_
is canceled.
This leads us directly to the more general asynchronous FFI
def async[A](k: (Either[Throwable, A] => Unit) => F[Option[F[Unit]]]): F[A]
As evidenced by the type signature, k
may perform F[_]
effects and it returns an
Option[F[Unit]]
which is an optional finalizer to be run in the event that the fiber
running
async(k)
is canceled.
- Source
- Async.scala
- Alphabetic
- By Inheritance
- Async
- GenTemporal
- GenConcurrent
- GenSpawn
- Sync
- Defer
- Unique
- Clock
- ClockPlatform
- MonadCancel
- MonadError
- Monad
- FlatMap
- FlatMapArityFunctions
- ApplicativeError
- Applicative
- InvariantMonoidal
- Apply
- ApplyArityFunctions
- InvariantSemigroupal
- Semigroupal
- Functor
- Invariant
- AsyncPlatform
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def canceled: F[Unit]
An effect that requests self-cancelation on the current fiber.
An effect that requests self-cancelation on the current fiber.
canceled
has a return type ofF[Unit]
instead ofF[Nothing]
due to execution continuing in a masked region. In the following example, the fiber requests self-cancelation in a masked region, so cancelation is suppressed until the fiber is completely unmasked.fa
will run butfb
will not. Ifcanceled
had a return type ofF[Nothing]
, then it would not be possible to continue execution tofa
(there would be noNothing
value to pass to theflatMap
).F.uncancelable { _ => F.canceled *> fa } *> fb
- Definition Classes
- MonadCancel
- abstract def cede: F[Unit]
Introduces a fairness boundary that yields control back to the scheduler of the runtime system.
Introduces a fairness boundary that yields control back to the scheduler of the runtime system. This allows the carrier thread to resume execution of another waiting fiber.
This function is primarily useful when performing long-running computation that is outside of the monadic context. For example:
fa.map(data => expensiveWork(data))
In the above, we're assuming that
expensiveWork
is a function which is entirely compute-bound but very long-running. A good rule of thumb is to consider a function "expensive" when its runtime is around three or more orders of magnitude higher than the overhead of themap
function itself (which runs in around 5 nanoseconds on modern hardware). Thus, anyexpensiveWork
function which requires around 10 microseconds or longer to execute should be considered "long-running".The danger is that these types of long-running actions outside of the monadic context can result in degraded fairness properties. The solution is to add an explicit
cede
both before and after the expensive operation:(fa <* F.cede).map(data => expensiveWork(data)).guarantee(F.cede)
Note that extremely long-running
expensiveWork
functions can still cause fairness issues, even when used withcede
. This problem is somewhat fundamental to the nature of scheduling such computation on carrier threads. Whenever possible, it is best to break apart any such functions into multiple pieces invoked independently (e.g. via chainedmap
calls) whenever the execution time exceeds five or six orders of magnitude beyond the overhead ofmap
itself (around 1 millisecond on most hardware).Note that
cede
is merely a hint to the runtime system; implementations have the liberty to interpret this method to their liking as long as it obeys the respective laws. For example, a lawful, but atypical, implementation of this function isF.unit
, in which case the fairness boundary is a no-op.- Definition Classes
- GenSpawn
- abstract def cont[K, R](body: Cont[F, K, R]): F[R]
- abstract def deferred[A]: F[Deferred[F, A]]
- Definition Classes
- GenConcurrent
- abstract def evalOn[A](fa: F[A], ec: ExecutionContext): F[A]
Shift execution of the effect
fa
to the execution contextec
.Shift execution of the effect
fa
to the execution contextec
. Execution is shifted back to the previous execution context whenfa
completes.evalOn(executionContext, ec) <-> pure(ec)
- abstract def executionContext: F[ExecutionContext]
Obtain a reference to the current execution context.
- abstract def flatMap[A, B](fa: F[A])(f: (A) => F[B]): F[B]
- Definition Classes
- FlatMap
- abstract def forceR[A, B](fa: F[A])(fb: F[B]): F[B]
Analogous to productR, but suppresses short-circuiting behavior except for cancelation.
Analogous to productR, but suppresses short-circuiting behavior except for cancelation.
- Definition Classes
- MonadCancel
- abstract def handleErrorWith[A](fa: F[A])(f: (Throwable) => F[A]): F[A]
- Definition Classes
- ApplicativeError
- abstract def monotonic: F[FiniteDuration]
Monotonic time subject to the law that (monotonic, monotonic).mapN(_ <= _)
Monotonic time subject to the law that (monotonic, monotonic).mapN(_ <= _)
Analogous to
java.lang.System.nanoTime
.- Definition Classes
- Clock
- abstract def onCancel[A](fa: F[A], fin: F[Unit]): F[A]
Registers a finalizer that is invoked if cancelation is observed during the evaluation of
fa
.Registers a finalizer that is invoked if cancelation is observed during the evaluation of
fa
. If the evaluation offa
completes without encountering a cancelation, the finalizer is unregistered before proceeding.Note that if
fa
is uncancelable (e.g. created via uncancelable) thenfin
won't be fired.F.onCancel(F.uncancelable(_ => F.canceled), fin) <-> F.unit
During finalization, all actively registered finalizers are run exactly once. The order by which finalizers are run is dictated by nesting: innermost finalizers are run before outermost finalizers. For example, in the following program, the finalizer
f1
is run before the finalizerf2
:F.onCancel(F.onCancel(F.canceled, f1), f2)
If a finalizer throws an error during evaluation, the error is suppressed, and implementations may choose to report it via a side channel. Finalizers are always uncancelable, so cannot otherwise be interrupted.
- fa
The effect that is evaluated after
fin
is registered.- fin
The finalizer to register before evaluating
fa
.
- Definition Classes
- MonadCancel
- abstract def pure[A](x: A): F[A]
- Definition Classes
- Applicative
- abstract def raiseError[A](e: Throwable): F[A]
- Definition Classes
- ApplicativeError
- abstract def realTime: F[FiniteDuration]
A representation of the current system time
A representation of the current system time
Analogous to
java.lang.System.currentTimeMillis
.- Definition Classes
- Clock
- abstract def ref[A](a: A): F[Ref[F, A]]
- Definition Classes
- GenConcurrent
- abstract def sleep(time: FiniteDuration): F[Unit]
- Attributes
- protected
- Definition Classes
- GenTemporal
- abstract def start[A](fa: F[A]): F[Fiber[F, Throwable, A]]
A low-level primitive for starting the concurrent evaluation of a fiber.
A low-level primitive for starting the concurrent evaluation of a fiber. Returns a Fiber that can be used to wait for a fiber or cancel it.
start is a cancelation-unsafe function; it is recommended to use the safer variant, background, to spawn fibers.
- fa
the effect for the fiber
- Definition Classes
- GenSpawn
- See also
background for the safer, recommended variant
- abstract def suspend[A](hint: Type)(thunk: => A): F[A]
- Definition Classes
- Sync
- abstract def tailRecM[A, B](a: A)(f: (A) => F[Either[A, B]]): F[B]
- Definition Classes
- FlatMap
- abstract def uncancelable[A](body: (Poll[F]) => F[A]): F[A]
Masks cancelation on the current fiber.
Masks cancelation on the current fiber. The argument to
body
of typePoll[F]
is a natural transformationF ~> F
that enables polling. Polling causes a fiber to unmask within a masked region so that cancelation can be observed again.In the following example, cancelation can be observed only within
fb
and nowhere else:F.uncancelable { poll => fa *> poll(fb) *> fc }
If a fiber is canceled while it is masked, the cancelation is suppressed for as long as the fiber remains masked. Whenever the fiber is completely unmasked again, the cancelation will be respected.
Masks can also be stacked or nested within each other. If multiple masks are active, all masks must be undone so that cancelation can be observed. In order to completely unmask within a multi-masked region the poll corresponding to each mask must be applied to the effect, outermost-first.
F.uncancelable { p1 => F.uncancelable { p2 => fa *> p2(p1(fb)) *> fc } }
The following operations are no-ops:
- Polling in the wrong order
- Subsequent polls when applying the same poll more than once:
poll(poll(fa))
is equivalent topoll(fa)
- Applying a poll bound to one fiber within another fiber
- body
A function which takes a Poll and returns the effect that we wish to make uncancelable.
- Definition Classes
- MonadCancel
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def *>[A, B](fa: F[A])(fb: F[B]): F[B]
- Definition Classes
- Apply
- Annotations
- @inline()
- final def <*[A, B](fa: F[A])(fb: F[B]): F[A]
- Definition Classes
- Apply
- Annotations
- @inline()
- final def <*>[A, B](ff: F[(A) => B])(fa: F[A]): F[B]
- Definition Classes
- Apply
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def adaptError[A](fa: F[A])(pf: PartialFunction[Throwable, Throwable]): F[A]
- Definition Classes
- MonadError → ApplicativeError
- def andWait[A](fa: F[A], time: FiniteDuration): F[A]
- Attributes
- protected
- Definition Classes
- GenTemporal
- def andWait[A](fa: F[A], time: Duration): F[A]
Wait for the specified duration after the execution of
fa
before returning the result.Wait for the specified duration after the execution of
fa
before returning the result.- fa
The effect to execute
- time
The duration to wait after executing fa
- Definition Classes
- GenTemporal
- def ap[A, B](ff: F[(A) => B])(fa: F[A]): F[B]
- Definition Classes
- FlatMap → Apply
- def ap10[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap11[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap12[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap13[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap14[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap15[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap16[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap17[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap18[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap19[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap2[A, B, Z](ff: F[(A, B) => Z])(fa: F[A], fb: F[B]): F[Z]
- Definition Classes
- FlatMap → Apply
- def ap20[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap21[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap22[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20], f21: F[A21]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap3[A0, A1, A2, Z](f: F[(A0, A1, A2) => Z])(f0: F[A0], f1: F[A1], f2: F[A2]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap4[A0, A1, A2, A3, Z](f: F[(A0, A1, A2, A3) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap5[A0, A1, A2, A3, A4, Z](f: F[(A0, A1, A2, A3, A4) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap6[A0, A1, A2, A3, A4, A5, Z](f: F[(A0, A1, A2, A3, A4, A5) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap7[A0, A1, A2, A3, A4, A5, A6, Z](f: F[(A0, A1, A2, A3, A4, A5, A6) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap8[A0, A1, A2, A3, A4, A5, A6, A7, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def ap9[A0, A1, A2, A3, A4, A5, A6, A7, A8, Z](f: F[(A0, A1, A2, A3, A4, A5, A6, A7, A8) => Z])(f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8]): F[Z]
- Definition Classes
- ApplyArityFunctions
- def applicative: Applicative[F]
- Definition Classes
- GenTemporal → Clock → GenSpawn → Unique
- def as[A, B](fa: F[A], b: B): F[B]
- Definition Classes
- Functor
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def async[A](k: ((Either[Throwable, A]) => Unit) => F[Option[F[Unit]]]): F[A]
Suspends an asynchronous side effect in
F
.Suspends an asynchronous side effect in
F
.The given function
k
will be invoked during evaluation of theF
to "schedule" the asynchronous callback, where the callback of typeEither[Throwable, A] => Unit
is the parameter passed to that function. Only the first invocation of the callback will be effective! All subsequent invocations will be silently dropped.The process of registering the callback itself is suspended in
F
(the outerF
ofF[Option[F[Unit]]]
).The effect returns
Option[F[Unit]]
which is an optional finalizer to be run in the event that the fiber runningasync(k)
is canceled.Also, note that
async
is uncancelable during its registration.- See also
async_ for a simplified variant without a finalizer
asyncCheckAttempt for more generic version with option of providing immediate result of computation
- def asyncCheckAttempt[A](k: ((Either[Throwable, A]) => Unit) => F[Either[Option[F[Unit]], A]]): F[A]
Suspends an asynchronous side effect with optional immediate result in
F
.Suspends an asynchronous side effect with optional immediate result in
F
.The given function
k
will be invoked during evaluation ofF
to:- check if result is already available;
- "schedule" the asynchronous callback, where the callback of type
Either[Throwable, A] \=> Unit
is the parameter passed to that function. Only the first invocation of the callback will be effective! All subsequent invocations will be silently dropped.
The process of registering the callback itself is suspended in
F
(the outerF
ofF[Either[Option[F[Unit]], A]]
).The effect returns
Either[Option[F[Unit]], A]
where:- right side
A
is an immediate result of computation (callback invocation will be dropped); - left side
Option[F[Unit]]
is an optional finalizer to be run in the event that the fiber runningasyncCheckAttempt(k)
is canceled.
Also, note that
asyncCheckAttempt
is uncancelable during its registration. - def async_[A](k: ((Either[Throwable, A]) => Unit) => Unit): F[A]
Suspends an asynchronous side effect in
F
.Suspends an asynchronous side effect in
F
.The given function
k
will be invoked during evaluation of theF
to "schedule" the asynchronous callback, where the callback is the parameter passed to that function. Only the first invocation of the callback will be effective! All subsequent invocations will be silently dropped.This function can be thought of as a safer, lexically-constrained version of
Promise
, whereIO
is like a safer, lazy version ofFuture
.Also, note that
async_
is uncancelable during its registration.- See also
async for more generic version providing a finalizer
asyncCheckAttempt for more generic version with option of providing immediate result of computation and finalizer
- def attempt[A](fa: F[A]): F[Either[Throwable, A]]
- Definition Classes
- ApplicativeError
- def attemptNarrow[EE <: Throwable, A](fa: F[A])(implicit tag: ClassTag[EE], ev: <:<[EE, Throwable]): F[Either[EE, A]]
- Definition Classes
- ApplicativeError
- def attemptT[A](fa: F[A]): EitherT[F, Throwable, A]
- Definition Classes
- ApplicativeError
- def attemptTap[A, B](fa: F[A])(f: (Either[Throwable, A]) => F[B]): F[A]
- Definition Classes
- MonadError
- def background[A](fa: F[A]): Resource[F, F[Outcome[F, Throwable, A]]]
Returns a Resource that manages the concurrent execution of a fiber.
Returns a Resource that manages the concurrent execution of a fiber. The inner effect can be used to wait on the outcome of the child fiber; it is effectively a join.
The child fiber is canceled in two cases: either the resource goes out of scope or the parent fiber is canceled. If the child fiber terminates before one of these cases occurs, then cancelation is a no-op. This avoids fiber leaks because the child fiber is always canceled before the parent fiber drops the reference to it.
// Starts a fiber that continously prints "A". // After 10 seconds, the resource scope exits so the fiber is canceled. F.background(F.delay(println("A")).foreverM).use { _ => F.sleep(10.seconds) }
- fa
the effect for the spawned fiber
- Definition Classes
- GenSpawn
- def backgroundOn[A](fa: F[A], ec: ExecutionContext): Resource[F, F[Outcome[F, Throwable, A]]]
Start a new background fiber on a different execution context.
Start a new background fiber on a different execution context.
See GenSpawn.background for more details.
- def blocking[A](thunk: => A): F[A]
Like Sync.delay but intended for thread blocking operations.
Like Sync.delay but intended for thread blocking operations.
blocking
will shift the execution of the blocking operation to a separate threadpool to avoid blocking on the main execution context. See the thread-model documentation for more information on why this is necessary. Note that the created effect will be uncancelable; if you need cancelation then you should use Sync.interruptible or Sync.interruptibleMany.Sync[F].blocking(scala.io.Source.fromFile("path").mkString)
- thunk
The side effect which is to be suspended in
F[_]
and evaluated on a blocking execution context
- Definition Classes
- Sync
- def both[A, B](fa: F[A], fb: F[B]): F[(A, B)]
Races the evaluation of two fibers and returns the result of both.
Races the evaluation of two fibers and returns the result of both.
The following rules describe the semantics of both:
- If the winner completes with Outcome.Succeeded, the race waits for the loser to complete. 2. If the winner completes with Outcome.Errored, the race raises the error. The loser is canceled. 3. If the winner completes with Outcome.Canceled, the loser and the race are canceled as well. 4. If the loser completes with Outcome.Succeeded, the race returns the successful value of both fibers. 5. If the loser completes with Outcome.Errored, the race returns the error. 6. If the loser completes with Outcome.Canceled, the race is canceled. 7. If the race is canceled before one or both participants complete, then whichever ones are incomplete are canceled. 8. If the race is masked and is canceled because one or both participants canceled, the fiber will block indefinitely.
- fa
the effect for the first racing fiber
- fb
the effect for the second racing fiber
- Definition Classes
- GenSpawn
- See also
bothOutcome for a variant that returns the Outcome of both fibers.
- def bothOutcome[A, B](fa: F[A], fb: F[B]): F[(Outcome[F, Throwable, A], Outcome[F, Throwable, B])]
Races the evaluation of two fibers and returns the Outcome of both.
Races the evaluation of two fibers and returns the Outcome of both. If the race is canceled before one or both participants complete, then then whichever ones are incomplete are canceled.
- fa
the effect for the first racing fiber
- fb
the effect for the second racing fiber
- def bracket[A, B](acquire: F[A])(use: (A) => F[B])(release: (A) => F[Unit]): F[B]
A pattern for safely interacting with effectful lifecycles.
A pattern for safely interacting with effectful lifecycles.
If
acquire
completes successfully,use
is called. Ifuse
succeeds, fails, or is canceled,release
is guaranteed to be called exactly once.acquire
is uncancelable.release
is uncancelable.use
is cancelable by default, but can be masked.- acquire
the lifecycle acquisition action
- use
the effect to which the lifecycle is scoped, whose result is the return value of this function
- release
the lifecycle release action
- Definition Classes
- MonadCancel
- See also
bracketCase for a more powerful variant
Resource for a composable datatype encoding of effectful lifecycles
- def bracketCase[A, B](acquire: F[A])(use: (A) => F[B])(release: (A, Outcome[F, Throwable, B]) => F[Unit]): F[B]
A pattern for safely interacting with effectful lifecycles.
A pattern for safely interacting with effectful lifecycles.
If
acquire
completes successfully,use
is called. Ifuse
succeeds, fails, or is canceled,release
is guaranteed to be called exactly once.acquire
is uncancelable.release
is uncancelable.use
is cancelable by default, but can be masked.- acquire
the lifecycle acquisition action
- use
the effect to which the lifecycle is scoped, whose result is the return value of this function
- release
the lifecycle release action which depends on the outcome of
use
- Definition Classes
- MonadCancel
- See also
bracketFull for a more powerful variant
Resource for a composable datatype encoding of effectful lifecycles
- def bracketFull[A, B](acquire: (Poll[F]) => F[A])(use: (A) => F[B])(release: (A, Outcome[F, Throwable, B]) => F[Unit]): F[B]
A pattern for safely interacting with effectful lifecycles.
A pattern for safely interacting with effectful lifecycles.
If
acquire
completes successfully,use
is called. Ifuse
succeeds, fails, or is canceled,release
is guaranteed to be called exactly once.If
use
succeeds the returned valueB
is returned. Ifuse
returns an exception, the exception is returned.acquire
is uncancelable by default, but can be unmasked.release
is uncancelable.use
is cancelable by default, but can be masked.- acquire
the lifecycle acquisition action which can be canceled
- use
the effect to which the lifecycle is scoped, whose result is the return value of this function
- release
the lifecycle release action which depends on the outcome of
use
- Definition Classes
- MonadCancel
- def cachedRealTime(ttl: Duration): F[F[FiniteDuration]]
Returns a nested effect which returns the time in a much faster way than
Clock[F]#realTime
.Returns a nested effect which returns the time in a much faster way than
Clock[F]#realTime
. This is achieved by caching the real time when the outer effect is run and, when the inner effect is run, the offset is used in combination withClock[F]#monotonic
to give an approximation of the real time. The practical benefit of this is a reduction in the number of syscalls, sincerealTime
will only be sequenced once perttl
window, and it tends to be (on most platforms) multiple orders of magnitude slower thanmonotonic
.This should generally be used in situations where precise "to the millisecond" alignment to the system real clock is not needed. In particular, if the system clock is updated (e.g. via an NTP sync), the inner effect will not observe that update until up to
ttl
. This is an acceptable tradeoff in most practical scenarios, particularly with frequent sequencing of the inner effect.- ttl
The period of time after which the cached real time will be refreshed. Note that it will only be refreshed upon execution of the nested effect
- Definition Classes
- GenTemporal
- def cancelable[A](fa: F[A], fin: F[Unit]): F[A]
Given an effect which might be uncancelable and a finalizer, produce an effect which can be canceled by running the finalizer.
Given an effect which might be uncancelable and a finalizer, produce an effect which can be canceled by running the finalizer. This combinator is useful for handling scenarios in which an effect is inherently uncancelable but may be canceled through setting some external state. A trivial example of this might be the following (assuming an Async instance):
val flag = new AtomicBoolean(false) val fa = F blocking { while (!flag.get()) { Thread.sleep(10) } } F.cancelable(fa, F.delay(flag.set(true)))
Without
cancelable
, effects constructed byblocking
,delay
, and similar are inherently uncancelable. Simply adding anonCancel
to such effects is insufficient to resolve this, despite the fact that under *some* circumstances (such as the above), it is possible to enrich an otherwise-uncancelable effect with early termination.cancelable
addresses this use-case.Note that there is no free lunch here. If an effect truly cannot be prematurely terminated,
cancelable
will not allow for cancelation. As an example, if you attempt to canceluncancelable(_ => never)
, the cancelation will hang forever (in other words, it will be itself equivalent tonever
). Applyingcancelable
will not change this in any way. Thus, attempting to cancelcancelable(uncancelable(_ => never), unit)
will also hang forever. As in all cases, cancelation will only return when all finalizers have run and the fiber has fully terminated.If
fa
self-cancels and thecancelable
itself is uncancelable, the resulting fiber will be equal tonever
(similar to race). Under normal circumstances, iffa
self-cancels, that cancelation will be propagated to the calling context.- fa
the effect to be canceled
- fin
an effect which orchestrates some external state which terminates
fa
- Definition Classes
- GenSpawn
- See also
- def catchNonFatal[A](a: => A)(implicit ev: <:<[Throwable, Throwable]): F[A]
- Definition Classes
- ApplicativeError
- def catchNonFatalEval[A](a: Eval[A])(implicit ev: <:<[Throwable, Throwable]): F[A]
- Definition Classes
- ApplicativeError
- def catchOnly[T >: Null <: Throwable]: CatchOnlyPartiallyApplied[T, F, Throwable]
- Definition Classes
- ApplicativeError
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def compose[G[_]](implicit arg0: Applicative[G]): Applicative[[α]F[G[α]]]
- Definition Classes
- Applicative
- def compose[G[_]](implicit arg0: Apply[G]): Apply[[α]F[G[α]]]
- Definition Classes
- Apply
- def compose[G[_]](implicit arg0: Functor[G]): Functor[[α]F[G[α]]]
- Definition Classes
- Functor
- def compose[G[_]](implicit arg0: Invariant[G]): Invariant[[α]F[G[α]]]
- Definition Classes
- Invariant
- def composeApply[G[_]](implicit arg0: Apply[G]): InvariantSemigroupal[[α]F[G[α]]]
- Definition Classes
- InvariantSemigroupal
- def composeContravariant[G[_]](implicit arg0: Contravariant[G]): Contravariant[[α]F[G[α]]]
- Definition Classes
- Functor → Invariant
- def composeContravariantMonoidal[G[_]](implicit arg0: ContravariantMonoidal[G]): ContravariantMonoidal[[α]F[G[α]]]
- Definition Classes
- Applicative
- def composeFunctor[G[_]](implicit arg0: Functor[G]): Invariant[[α]F[G[α]]]
- Definition Classes
- Invariant
- def defer[A](thunk: => F[A]): F[A]
Suspends the evaluation of an
F[_]
reference.Suspends the evaluation of an
F[_]
reference.Equivalent to
FlatMap.flatten
for pure expressions, the purpose of this function is to suspend side effects inF[_]
.- Definition Classes
- Sync → Defer
- def delay[A](thunk: => A): F[A]
The synchronous FFI - lifts any by-name parameter into the
F[_]
context.The synchronous FFI - lifts any by-name parameter into the
F[_]
context.Equivalent to Applicative.pure for pure expressions, the purpose of this function is to suspend side effects in
F
. Use Sync.delay if your side effect is not thread-blocking; otherwise you should use Sync.blocking (uncancelable) or Sync.interruptible (cancelable).- thunk
The side effect which is to be suspended in
F[_]
- Definition Classes
- Sync
- def delayBy[A](fa: F[A], time: FiniteDuration): F[A]
- Attributes
- protected
- Definition Classes
- GenTemporal
- def delayBy[A](fa: F[A], time: Duration): F[A]
Delay the execution of
fa
by a given duration.Delay the execution of
fa
by a given duration.- fa
The effect to execute
- time
The duration to wait before executing fa
- Definition Classes
- GenTemporal
- def ensure[A](fa: F[A])(error: => Throwable)(predicate: (A) => Boolean): F[A]
- Definition Classes
- MonadError
- def ensureOr[A](fa: F[A])(error: (A) => Throwable)(predicate: (A) => Boolean): F[A]
- Definition Classes
- MonadError
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def evalOnK(ec: ExecutionContext): ~>[F, F]
Async.evalOn as a natural transformation.
- def executor: F[Executor]
Obtain a reference to the current execution context as a
java.util.concurrent.Executor
. - def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def fix[A](fn: (F[A]) => F[A]): F[A]
- Definition Classes
- Defer
- def flatMap10[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap11[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap12[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap13[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap14[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap15[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap16[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap17[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap18[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap19[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap2[A0, A1, Z](f0: F[A0], f1: F[A1])(f: (A0, A1) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap20[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap21[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap22[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20], f21: F[A21])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap3[A0, A1, A2, Z](f0: F[A0], f1: F[A1], f2: F[A2])(f: (A0, A1, A2) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap4[A0, A1, A2, A3, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3])(f: (A0, A1, A2, A3) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap5[A0, A1, A2, A3, A4, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4])(f: (A0, A1, A2, A3, A4) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap6[A0, A1, A2, A3, A4, A5, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5])(f: (A0, A1, A2, A3, A4, A5) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap7[A0, A1, A2, A3, A4, A5, A6, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6])(f: (A0, A1, A2, A3, A4, A5, A6) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap8[A0, A1, A2, A3, A4, A5, A6, A7, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7])(f: (A0, A1, A2, A3, A4, A5, A6, A7) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatMap9[A0, A1, A2, A3, A4, A5, A6, A7, A8, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8) => F[Z]): F[Z]
- Definition Classes
- FlatMapArityFunctions
- def flatTap[A, B](fa: F[A])(f: (A) => F[B]): F[A]
- Definition Classes
- FlatMap
- def flatten[A](ffa: F[F[A]]): F[A]
- Definition Classes
- FlatMap
- final def fmap[A, B](fa: F[A])(f: (A) => B): F[B]
- Definition Classes
- Functor
- def foreverM[A, B](fa: F[A]): F[B]
- Definition Classes
- FlatMap
- def fproduct[A, B](fa: F[A])(f: (A) => B): F[(A, B)]
- Definition Classes
- Functor
- def fproductLeft[A, B](fa: F[A])(f: (A) => B): F[(B, A)]
- Definition Classes
- Functor
- def fromCompletableFuture[A](fut: F[CompletableFuture[A]]): F[A]
Suspend a
java.util.concurrent.CompletableFuture
into theF[_]
context.Suspend a
java.util.concurrent.CompletableFuture
into theF[_]
context.- fut
The
java.util.concurrent.CompletableFuture
to suspend inF[_]
- Definition Classes
- AsyncPlatform
- Note
Cancelation is cooperative and it is up to the
CompletableFuture
to respond to the request by handling cancelation appropriately and indicating that it has done so. This means that if theCompletableFuture
indicates that it did not cancel, there will be no "fire-and-forget" semantics. Instead, to satisfy backpressure guarantees, theCompletableFuture
will be treated as if it is uncancelable and the fiber will fallback to waiting for it to complete.
- def fromCompletionStage[A](completionStage: F[CompletionStage[A]]): F[A]
- Definition Classes
- AsyncPlatform
- def fromEither[A](x: Either[Throwable, A]): F[A]
- Definition Classes
- ApplicativeError
- def fromFuture[A](fut: F[Future[A]]): F[A]
Lifts a scala.concurrent.Future into an
F
effect.Lifts a scala.concurrent.Future into an
F
effect.- See also
fromFutureCancelable for a cancelable version
- def fromFutureCancelable[A](futCancel: F[(Future[A], F[Unit])]): F[A]
Like fromFuture, but is cancelable via the provided finalizer.
- def fromOption[A](oa: Option[A], ifEmpty: => Throwable): F[A]
- Definition Classes
- ApplicativeError
- def fromTry[A](t: Try[A])(implicit ev: <:<[Throwable, Throwable]): F[A]
- Definition Classes
- ApplicativeError
- def fromValidated[A](x: Validated[Throwable, A]): F[A]
- Definition Classes
- ApplicativeError
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def guarantee[A](fa: F[A], fin: F[Unit]): F[A]
Specifies an effect that is always invoked after evaluation of
fa
completes, regardless of the outcome.Specifies an effect that is always invoked after evaluation of
fa
completes, regardless of the outcome.This function can be thought of as a combination of flatTap, onError, and onCancel.
- fa
The effect that is run after
fin
is registered.- fin
The effect to run in the event of a cancelation or error.
- Definition Classes
- MonadCancel
- See also
guaranteeCase for a more powerful variant
Outcome for the various outcomes of evaluation
- def guaranteeCase[A](fa: F[A])(fin: (Outcome[F, Throwable, A]) => F[Unit]): F[A]
Specifies an effect that is always invoked after evaluation of
fa
completes, but depends on the outcome.Specifies an effect that is always invoked after evaluation of
fa
completes, but depends on the outcome.This function can be thought of as a combination of flatTap, onError, and onCancel.
- fa
The effect that is run after
fin
is registered.- fin
A function that returns the effect to run based on the outcome.
- Definition Classes
- MonadCancel
- See also
bracketCase for a more powerful variant
Outcome for the various outcomes of evaluation
- def handleError[A](fa: F[A])(f: (Throwable) => A): F[A]
- Definition Classes
- ApplicativeError
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def ifElseM[A](branches: (F[Boolean], F[A])*)(els: F[A]): F[A]
- Definition Classes
- Monad
- def ifF[A](fb: F[Boolean])(ifTrue: => A, ifFalse: => A): F[A]
- Definition Classes
- Functor
- def ifM[B](fa: F[Boolean])(ifTrue: => F[B], ifFalse: => F[B]): F[B]
- Definition Classes
- FlatMap
- def imap[A, B](fa: F[A])(f: (A) => B)(g: (B) => A): F[B]
- Definition Classes
- Functor → Invariant
- def interruptible[A](thunk: => A): F[A]
Like Sync.blocking but will attempt to abort the blocking operation using thread interrupts in the event of cancelation.
Like Sync.blocking but will attempt to abort the blocking operation using thread interrupts in the event of cancelation. The interrupt will be attempted only once.
- thunk
The side effect which is to be suspended in
F[_]
and evaluated on a blocking execution context
- Definition Classes
- Sync
- def interruptibleMany[A](thunk: => A): F[A]
Like Sync.blocking but will attempt to abort the blocking operation using thread interrupts in the event of cancelation.
Like Sync.blocking but will attempt to abort the blocking operation using thread interrupts in the event of cancelation. The interrupt will be attempted repeatedly until the blocking operation completes or exits.
- thunk
The side effect which is to be suspended in
F[_]
and evaluated on a blocking execution context
- Definition Classes
- Sync
- Note
that this _really_ means what it says - it will throw exceptions in a tight loop until the offending blocking operation exits. This is extremely expensive if it happens on a hot path and the blocking operation is badly behaved and doesn't exit immediately.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterateForeverM[A, B](a: A)(f: (A) => F[A]): F[B]
- Definition Classes
- FlatMap
- def iterateUntil[A](f: F[A])(p: (A) => Boolean): F[A]
- Definition Classes
- Monad
- def iterateUntilM[A](init: A)(f: (A) => F[A])(p: (A) => Boolean): F[A]
- Definition Classes
- Monad
- def iterateWhile[A](f: F[A])(p: (A) => Boolean): F[A]
- Definition Classes
- Monad
- def iterateWhileM[A](init: A)(f: (A) => F[A])(p: (A) => Boolean): F[A]
- Definition Classes
- Monad
- def lift[A, B](f: (A) => B): (F[A]) => F[B]
- Definition Classes
- Functor
- def map[A, B](fa: F[A])(f: (A) => B): F[B]
- Definition Classes
- Monad → Applicative → Functor
- def map10[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map11[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map12[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map13[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map14[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map15[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map16[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map17[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map18[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map19[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map2[A, B, Z](fa: F[A], fb: F[B])(f: (A, B) => Z): F[Z]
- Definition Classes
- FlatMap → Apply
- def map20[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map21[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map22[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20], f21: F[A21])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map2Eval[A, B, Z](fa: F[A], fb: Eval[F[B]])(f: (A, B) => Z): Eval[F[Z]]
- Definition Classes
- FlatMap → Apply
- def map3[A0, A1, A2, Z](f0: F[A0], f1: F[A1], f2: F[A2])(f: (A0, A1, A2) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map4[A0, A1, A2, A3, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3])(f: (A0, A1, A2, A3) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map5[A0, A1, A2, A3, A4, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4])(f: (A0, A1, A2, A3, A4) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map6[A0, A1, A2, A3, A4, A5, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5])(f: (A0, A1, A2, A3, A4, A5) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map7[A0, A1, A2, A3, A4, A5, A6, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6])(f: (A0, A1, A2, A3, A4, A5, A6) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map8[A0, A1, A2, A3, A4, A5, A6, A7, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7])(f: (A0, A1, A2, A3, A4, A5, A6, A7) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def map9[A0, A1, A2, A3, A4, A5, A6, A7, A8, Z](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8])(f: (A0, A1, A2, A3, A4, A5, A6, A7, A8) => Z): F[Z]
- Definition Classes
- ApplyArityFunctions
- def memoize[A](fa: F[A]): F[F[A]]
Caches the result of
fa
.Caches the result of
fa
.The returned inner effect, hence referred to as
get
, when sequenced, will evaluatefa
and cache the result. Ifget
is sequenced multiple timesfa
will only be evaluated once.If all
get
s are canceled prior tofa
completing, it will be canceled and evaluated again the next timeget
is sequenced.- Definition Classes
- GenConcurrent
- def mproduct[A, B](fa: F[A])(f: (A) => F[B]): F[(A, B)]
- Definition Classes
- FlatMap
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def never[A]: F[A]
An effect that never terminates.
An effect that never terminates.
Polymorphic so it can be used in situations where an arbitrary effect is expected eg Fiber.joinWithNever
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def onError[A](fa: F[A])(pf: PartialFunction[Throwable, F[Unit]]): F[A]
- Definition Classes
- ApplicativeError
- def parReplicateAN[A](n: Int)(replicas: Int, ma: F[A]): F[List[A]]
Like
Parallel.parReplicateA
, but limits the degree of parallelism.Like
Parallel.parReplicateA
, but limits the degree of parallelism.- Definition Classes
- GenConcurrent
- def parSequenceN[T[_], A](n: Int)(tma: T[F[A]])(implicit arg0: Traverse[T]): F[T[A]]
Like
Parallel.parSequence
, but limits the degree of parallelism.Like
Parallel.parSequence
, but limits the degree of parallelism.- Definition Classes
- GenConcurrent
- def parTraverseN[T[_], A, B](n: Int)(ta: T[A])(f: (A) => F[B])(implicit arg0: Traverse[T]): F[T[B]]
Like
Parallel.parTraverse
, but limits the degree of parallelism.Like
Parallel.parTraverse
, but limits the degree of parallelism. Note that the semantics of this operation aim to maximise fairness: when a spot to execute becomes available, every task has a chance to claim it, and not only the nextn
tasks inta
- Definition Classes
- GenConcurrent
- def point[A](a: A): F[A]
- Definition Classes
- InvariantMonoidal
- def product[A, B](fa: F[A], fb: F[B]): F[(A, B)]
- Definition Classes
- FlatMap → Apply → Semigroupal
- def productL[A, B](fa: F[A])(fb: F[B]): F[A]
- Definition Classes
- FlatMap → Apply
- def productLEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A]
- Definition Classes
- FlatMap
- def productR[A, B](fa: F[A])(fb: F[B]): F[B]
- Definition Classes
- FlatMap → Apply
- def productREval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B]
- Definition Classes
- FlatMap
- def race[A, B](fa: F[A], fb: F[B]): F[Either[A, B]]
Races the evaluation of two fibers that returns the result of the winner, except in the case of cancelation.
Races the evaluation of two fibers that returns the result of the winner, except in the case of cancelation.
The semantics of race are described by the following rules:
- If the winner completes with Outcome.Succeeded, the race returns the successful value. The loser is canceled before returning. 2. If the winner completes with Outcome.Errored, the race raises the error. The loser is canceled before returning. 3. If the winner completes with Outcome.Canceled, the race returns the result of the loser, consistent with the first two rules. 4. If both the winner and loser complete with Outcome.Canceled, the race is canceled. 8. If the race is masked and is canceled because both participants canceled, the fiber will block indefinitely.
- fa
the effect for the first racing fiber
- fb
the effect for the second racing fiber
- Definition Classes
- GenSpawn
- See also
raceOutcome for a variant that returns the outcome of the winner.
- def raceOutcome[A, B](fa: F[A], fb: F[B]): F[Either[Outcome[F, Throwable, A], Outcome[F, Throwable, B]]]
Races the evaluation of two fibers that returns the Outcome of the winner.
Races the evaluation of two fibers that returns the Outcome of the winner. The winner of the race is considered to be the first fiber that completes with an outcome. The loser of the race is canceled before returning.
- fa
the effect for the first racing fiber
- fb
the effect for the second racing fiber
- def racePair[A, B](fa: F[A], fb: F[B]): F[Either[(Outcome[F, Throwable, A], Fiber[F, Throwable, B]), (Fiber[F, Throwable, A], Outcome[F, Throwable, B])]]
A low-level primitive for racing the evaluation of two fibers that returns the Outcome of the winner and the Fiber of the loser.
A low-level primitive for racing the evaluation of two fibers that returns the Outcome of the winner and the Fiber of the loser. The winner of the race is considered to be the first fiber that completes with an outcome.
racePair is a cancelation-unsafe function; it is recommended to use the safer variants.
- fa
the effect for the first racing fiber
- fb
the effect for the second racing fiber
- Definition Classes
- GenConcurrent → GenSpawn
- See also
raceOutcome and race for safer race variants.
- def raiseUnless(cond: Boolean)(e: => Throwable): F[Unit]
- Definition Classes
- ApplicativeError
- def raiseWhen(cond: Boolean)(e: => Throwable): F[Unit]
- Definition Classes
- ApplicativeError
- def realTimeInstant: F[Instant]
- Definition Classes
- ClockPlatform
- def recover[A](fa: F[A])(pf: PartialFunction[Throwable, A]): F[A]
- Definition Classes
- ApplicativeError
- def recoverWith[A](fa: F[A])(pf: PartialFunction[Throwable, F[A]]): F[A]
- Definition Classes
- ApplicativeError
- def redeem[A, B](fa: F[A])(recover: (Throwable) => B, f: (A) => B): F[B]
- Definition Classes
- ApplicativeError
- def redeemWith[A, B](fa: F[A])(recover: (Throwable) => F[B], bind: (A) => F[B]): F[B]
- Definition Classes
- MonadError
- def replicateA[A](n: Int, fa: F[A]): F[List[A]]
- Definition Classes
- Applicative
- def replicateA_[A](n: Int, fa: F[A]): F[Unit]
- Definition Classes
- Applicative
- def rethrow[A, EE <: Throwable](fa: F[Either[EE, A]]): F[A]
- Definition Classes
- MonadError
- final def rootCancelScope: CancelScope
Indicates the default "root scope" semantics of the
F
in question.Indicates the default "root scope" semantics of the
F
in question. For types which do not implement auto-cancelation, this value may be set toCancelScope.Uncancelable
, which behaves as if all valuesF[A]
are wrapped in an implicit "outer"uncancelable
which cannot be polled. MostIO
-like types will define this to beCancelable
.- Definition Classes
- GenSpawn → MonadCancel
- def sleep(time: Duration): F[Unit]
Semantically block the fiber for the specified duration.
Semantically block the fiber for the specified duration.
- time
The duration to semantically block for
- Definition Classes
- GenTemporal
- def startOn[A](fa: F[A], ec: ExecutionContext): F[Fiber[F, Throwable, A]]
Start a new fiber on a different execution context.
Start a new fiber on a different execution context.
See GenSpawn.start for more details.
- def syncStep[G[_], A](fa: F[A], limit: Int)(implicit G: Sync[G]): G[Either[F[A], A]]
Translates this
F[A]
into aG
value which, when evaluated, runs the originalF
to its completion, thelimit
number of stages, or until the first stage that cannot be expressed with Sync (typically an asynchronous boundary).Translates this
F[A]
into aG
value which, when evaluated, runs the originalF
to its completion, thelimit
number of stages, or until the first stage that cannot be expressed with Sync (typically an asynchronous boundary).Note that
syncStep
is merely a hint to the runtime system; implementations have the liberty to interpret this method to their liking as long as it obeys the respective laws. For example, a lawful implementation of this function isG.pure(Left(fa))
, in which case the originalF[A]
value is returned unchanged.- limit
The maximum number of stages to evaluate prior to forcibly yielding to
F
- Annotations
- @nowarn()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def timed[A](fa: F[A]): F[(FiniteDuration, A)]
Returns an effect that completes with the result of the source together with the duration that it took to complete.
Returns an effect that completes with the result of the source together with the duration that it took to complete.
- fa
The effect which we wish to time the execution of
- Definition Classes
- Clock
- def timeout[A](fa: F[A], duration: FiniteDuration)(implicit ev: <:<[TimeoutException, Throwable]): F[A]
- Attributes
- protected
- Definition Classes
- GenTemporal
- def timeout[A](fa: F[A], duration: Duration)(implicit ev: <:<[TimeoutException, Throwable]): F[A]
Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise raises aTimeoutException
.Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise raises aTimeoutException
.The source is canceled in the event that it takes longer than the specified time duration to complete. Once the source has been successfully canceled (and has completed its finalizers), the
TimeoutException
will be raised. If the source is uncancelable, the resulting effect will wait for it to complete before raising the exception.- duration
The time span for which we wait for the source to complete; in the event that the specified time has passed without the source completing, a
TimeoutException
is raised
- Definition Classes
- GenTemporal
- def timeoutAndForget[A](fa: F[A], duration: FiniteDuration)(implicit ev: <:<[TimeoutException, Throwable]): F[A]
- Attributes
- protected
- Definition Classes
- GenTemporal
- def timeoutAndForget[A](fa: F[A], duration: Duration)(implicit ev: <:<[TimeoutException, Throwable]): F[A]
Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise raises aTimeoutException
.Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise raises aTimeoutException
.The source is canceled in the event that it takes longer than the specified time duration to complete. Unlike timeout, the cancelation of the source will be requested but not awaited, and the exception will be raised immediately upon the completion of the timer. This may more closely match intuitions about timeouts, but it also violates backpressure guarantees and intentionally leaks fibers.
This combinator should be applied very carefully.
- duration
The time span for which we wait for the source to complete; in the event that the specified time has passed without the source completing, a
TimeoutException
is raised
- Definition Classes
- GenTemporal
- See also
timeout for a variant which respects backpressure and does not leak fibers
- def timeoutTo[A](fa: F[A], duration: FiniteDuration, fallback: F[A]): F[A]
- Attributes
- protected
- Definition Classes
- GenTemporal
- def timeoutTo[A](fa: F[A], duration: Duration, fallback: F[A]): F[A]
Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise evaluates thefallback
.Returns an effect that either completes with the result of the source within the specified time
duration
or otherwise evaluates thefallback
.The source is canceled in the event that it takes longer than the specified time duration to complete. Once the source has been successfully canceled (and has completed its finalizers), the fallback will be sequenced. If the source is uncancelable, the resulting effect will wait for it to complete before evaluating the fallback.
- duration
The time span for which we wait for the source to complete; in the event that the specified time has passed without the source completing, the
fallback
gets evaluated- fallback
The task evaluated after the duration has passed and the source canceled
- Definition Classes
- GenTemporal
- def toString(): String
- Definition Classes
- AnyRef → Any
- def tuple10[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)]
- Definition Classes
- ApplyArityFunctions
- def tuple11[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)]
- Definition Classes
- ApplyArityFunctions
- def tuple12[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)]
- Definition Classes
- ApplyArityFunctions
- def tuple13[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)]
- Definition Classes
- ApplyArityFunctions
- def tuple14[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)]
- Definition Classes
- ApplyArityFunctions
- def tuple15[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)]
- Definition Classes
- ApplyArityFunctions
- def tuple16[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)]
- Definition Classes
- ApplyArityFunctions
- def tuple17[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)]
- Definition Classes
- ApplyArityFunctions
- def tuple18[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17)]
- Definition Classes
- ApplyArityFunctions
- def tuple19[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18)]
- Definition Classes
- ApplyArityFunctions
- def tuple2[A, B](f1: F[A], f2: F[B]): F[(A, B)]
- Definition Classes
- ApplyArityFunctions
- def tuple20[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19)]
- Definition Classes
- ApplyArityFunctions
- def tuple21[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)]
- Definition Classes
- ApplyArityFunctions
- def tuple22[A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8], f9: F[A9], f10: F[A10], f11: F[A11], f12: F[A12], f13: F[A13], f14: F[A14], f15: F[A15], f16: F[A16], f17: F[A17], f18: F[A18], f19: F[A19], f20: F[A20], f21: F[A21]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21)]
- Definition Classes
- ApplyArityFunctions
- def tuple3[A0, A1, A2](f0: F[A0], f1: F[A1], f2: F[A2]): F[(A0, A1, A2)]
- Definition Classes
- ApplyArityFunctions
- def tuple4[A0, A1, A2, A3](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3]): F[(A0, A1, A2, A3)]
- Definition Classes
- ApplyArityFunctions
- def tuple5[A0, A1, A2, A3, A4](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4]): F[(A0, A1, A2, A3, A4)]
- Definition Classes
- ApplyArityFunctions
- def tuple6[A0, A1, A2, A3, A4, A5](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5]): F[(A0, A1, A2, A3, A4, A5)]
- Definition Classes
- ApplyArityFunctions
- def tuple7[A0, A1, A2, A3, A4, A5, A6](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6]): F[(A0, A1, A2, A3, A4, A5, A6)]
- Definition Classes
- ApplyArityFunctions
- def tuple8[A0, A1, A2, A3, A4, A5, A6, A7](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7]): F[(A0, A1, A2, A3, A4, A5, A6, A7)]
- Definition Classes
- ApplyArityFunctions
- def tuple9[A0, A1, A2, A3, A4, A5, A6, A7, A8](f0: F[A0], f1: F[A1], f2: F[A2], f3: F[A3], f4: F[A4], f5: F[A5], f6: F[A6], f7: F[A7], f8: F[A8]): F[(A0, A1, A2, A3, A4, A5, A6, A7, A8)]
- Definition Classes
- ApplyArityFunctions
- def tupleLeft[A, B](fa: F[A], b: B): F[(B, A)]
- Definition Classes
- Functor
- def tupleRight[A, B](fa: F[A], b: B): F[(A, B)]
- Definition Classes
- Functor
- def unique: F[Token]
Yields a value that is guaranteed to be unique ie (F.unique, F.unique).mapN(_ =!= _)
- def unit: F[Unit]
- Definition Classes
- Applicative → InvariantMonoidal
- def unlessA[A](cond: Boolean)(f: => F[A]): F[Unit]
- Definition Classes
- Applicative
- def untilDefinedM[A](foa: F[Option[A]]): F[A]
- Definition Classes
- FlatMap
- def untilM[G[_], A](f: F[A])(cond: => F[Boolean])(implicit G: Alternative[G]): F[G[A]]
- Definition Classes
- Monad
- def untilM_[A](f: F[A])(cond: => F[Boolean]): F[Unit]
- Definition Classes
- Monad
- def unzip[A, B](fab: F[(A, B)]): (F[A], F[B])
- Definition Classes
- Functor
- def void[A](fa: F[A]): F[Unit]
- Definition Classes
- Functor
- def voidError(fu: F[Unit]): F[Unit]
- Definition Classes
- ApplicativeError
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def whenA[A](cond: Boolean)(f: => F[A]): F[Unit]
- Definition Classes
- Applicative
- def whileM[G[_], A](p: F[Boolean])(body: => F[A])(implicit G: Alternative[G]): F[G[A]]
- Definition Classes
- Monad
- def whileM_[A](p: F[Boolean])(body: => F[A]): F[Unit]
- Definition Classes
- Monad
- def widen[A, B >: A](fa: F[A]): F[B]
- Definition Classes
- Functor