A fiber is a lightweight thread of execution that never consumes more than a whole thread (but may consume much less, depending on contention and asynchronicity). Fibers are spawned by forking ZIO effects, which run concurrently with the parent effect.
Fibers can be joined, yielding their result to other fibers, or interrupted, which terminates the fiber, safely releasing all resources.
def parallel[A, B](io1: Task[A], io2: Task[B]): Task[(A, B)] =
for {
fiber1 <- io1.fork
fiber2 <- io2.fork
a <- fiber1.join
b <- fiber2.join
} yield (a, b)
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Members list
Value members
Abstract methods
Awaits the fiber, which suspends the awaiting fiber until the result of the fiber has been determined.
Awaits the fiber, which suspends the awaiting fiber until the result of the fiber has been determined.
Attributes
- Returns
-
UIO[Exit[E, A]]
Retrieves the immediate children of the fiber.
Retrieves the immediate children of the fiber.
Attributes
In the background, interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
In the background, interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Attributes
- Returns
-
UIO[Exit, E, A]]
Concrete methods
Same as zip
but discards the output of the left hand side.
Same as zip
but discards the output of the left hand side.
Type parameters
- B
-
type of the fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, B]
combined fiber
Same as zip
but discards the output of the right hand side.
Same as zip
but discards the output of the right hand side.
Type parameters
- B
-
type of the fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, A]
combined fiber
Zips this fiber and the specified fiber together, producing a tuple of their output.
Zips this fiber and the specified fiber together, producing a tuple of their output.
Type parameters
- B
-
type of that fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, (A, B)]
combined fiber
A symbolic alias for orElseEither
.
A symbolic alias for orElseEither
.
Attributes
A symbolic alias for orElse
.
A symbolic alias for orElse
.
Attributes
Maps the output of this fiber to the specified constant.
Maps the output of this fiber to the specified constant.
Type parameters
- B
-
type of the fiber
Value parameters
- b
-
constant
Attributes
- Returns
-
Fiber[E, B]
fiber mapped to constant
Folds over the runtime or synthetic fiber.
Folds over the runtime or synthetic fiber.
Attributes
Interrupts the fiber from whichever fiber is calling this method. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Interrupts the fiber from whichever fiber is calling this method. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Attributes
- Returns
-
UIO[Exit, E, A]]
Interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Attributes
- Returns
-
UIO[Exit, E, A]]
Interrupts the fiber from whichever fiber is calling this method. The interruption will happen in a separate daemon fiber, and the returned effect will always resume immediately without waiting.
Interrupts the fiber from whichever fiber is calling this method. The interruption will happen in a separate daemon fiber, and the returned effect will always resume immediately without waiting.
Attributes
- Returns
-
UIO[Unit]
Joins the fiber, which suspends the joining fiber until the result of the fiber has been determined. Attempting to join a fiber that has erred will result in a catchable error. Joining an interrupted fiber will result in an "inner interruption" of this fiber, unlike interruption triggered by another fiber, "inner interruption" can be caught and recovered.
Joins the fiber, which suspends the joining fiber until the result of the fiber has been determined. Attempting to join a fiber that has erred will result in a catchable error. Joining an interrupted fiber will result in an "inner interruption" of this fiber, unlike interruption triggered by another fiber, "inner interruption" can be caught and recovered.
Attributes
- Returns
-
IO[E, A]
Maps over the value the Fiber computes.
Maps over the value the Fiber computes.
Type parameters
- B
-
result type of f
Value parameters
- f
-
mapping function
Attributes
- Returns
-
Fiber[E, B]
mapped fiber
Passes the success of this fiber to the specified callback, and continues with the fiber that it returns.
Passes the success of this fiber to the specified callback, and continues with the fiber that it returns.
Type parameters
- B
-
The success value.
Value parameters
- f
-
The callback.
Attributes
- Returns
-
Fiber[E, B]
The continued fiber.
Effectually maps over the value the fiber computes.
Effectually maps over the value the fiber computes.
Attributes
Returns a fiber that prefers this
fiber, but falls back to the that
one when this
one fails. Interrupting the returned fiber will interrupt both fibers, sequentially, from left to right.
Returns a fiber that prefers this
fiber, but falls back to the that
one when this
one fails. Interrupting the returned fiber will interrupt both fibers, sequentially, from left to right.
Type parameters
- A1
-
type of the other fiber
- E1
-
error type
Value parameters
- that
-
fiber to fall back to
Attributes
- Returns
-
Fiber[E1, A1]
Returns a fiber that prefers this
fiber, but falls back to the that
one when this
one fails. Interrupting the returned fiber will interrupt both fibers, sequentially, from left to right.
Returns a fiber that prefers this
fiber, but falls back to the that
one when this
one fails. Interrupting the returned fiber will interrupt both fibers, sequentially, from left to right.
Type parameters
- B
-
type of the other fiber
- E1
-
error type
Value parameters
- that
-
fiber to fall back to
Attributes
- Returns
-
Fiber[E1, B]
Converts this fiber into a scala.concurrent.Future.
Converts this fiber into a scala.concurrent.Future.
Value parameters
- ev
-
implicit witness that E is a subtype of Throwable
Attributes
- Returns
-
UIO[Future[A]]
Converts this fiber into a scala.concurrent.Future, translating any errors to java.lang.Throwable with the specified conversion function, using Cause.squashTraceWith
Converts this fiber into a scala.concurrent.Future, translating any errors to java.lang.Throwable with the specified conversion function, using Cause.squashTraceWith
Value parameters
- f
-
function to the error into a Throwable
Attributes
- Returns
-
UIO[Future[A]]
Maps the output of this fiber to ()
.
Maps the output of this fiber to ()
.
Attributes
- Returns
-
Fiber[E, Unit]
fiber mapped to()
Named alias for <*>
.
Named alias for <*>
.
Type parameters
- B
-
type of that fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, (A, B)]
combined fiber
Named alias for <*
.
Named alias for <*
.
Type parameters
- B
-
type of the fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, A]
combined fiber
Named alias for *>
.
Named alias for *>
.
Type parameters
- B
-
type of the fiber
- E1
-
error type
Value parameters
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, B]
combined fiber
Zips this fiber with the specified fiber, combining their results using the specified combiner function. Both joins and interruptions are performed in sequential order from left to right.
Zips this fiber with the specified fiber, combining their results using the specified combiner function. Both joins and interruptions are performed in sequential order from left to right.
Type parameters
- B
-
type of that fiber
- C
-
type of the resulting fiber
- E1
-
error type
Value parameters
- f
-
function to combine the results of both fibers
- that
-
fiber to be zipped
Attributes
- Returns
-
Fiber[E1, C]
combined fiber