Trait/Object

zio

Fiber

Related Docs: object Fiber | package zio

Permalink

trait Fiber[+E, +A] extends AnyRef

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)
Self Type
Fiber[E, A]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Fiber
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def await: UIO[Exit[E, A]]

    Permalink

    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.

    returns

    UIO[Exit[E, A]]

  2. abstract def children: UIO[Iterable[Fiber[Any, Any]]]

    Permalink

    Children of the fiber.

  3. abstract def getRef[A](ref: FiberRef[A]): UIO[A]

    Permalink

    Gets the value of the fiber ref for this fiber, or the initial value of the fiber ref, if the fiber is not storing the ref.

  4. abstract def id: UIO[Option[Id]]

    Permalink

    The identity of the fiber, if it is a single runtime fiber.

    The identity of the fiber, if it is a single runtime fiber. Fibers created from values or composite fibers do not have identities.

  5. abstract def inheritRefs: UIO[Unit]

    Permalink

    Inherits values from all FiberRef instances into current fiber.

    Inherits values from all FiberRef instances into current fiber. This will resume immediately.

    returns

    UIO[Unit]

  6. abstract def interruptAs(fiberId: Id): UIO[Exit[E, A]]

    Permalink

    Interrupts the fiber as if interrupted from the specified fiber.

    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.

    returns

    UIO[Exit, E, A]]

  7. abstract def poll: UIO[Option[Exit[E, A]]]

    Permalink

    Tentatively observes the fiber, but returns immediately if it is not already done.

    Tentatively observes the fiber, but returns immediately if it is not already done.

    returns

    UIO[Option[Exit, E, A]]]

  8. abstract def status: UIO[Status]

    Permalink

    The status of the fiber.

  9. abstract def trace: UIO[Option[ZTrace]]

    Permalink

    The trace of the fiber.

    The trace of the fiber. Currently only single runtime fibers have traces.

Concrete Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def *>[E1 >: E, B](that: Fiber[E1, B]): Fiber[E1, B]

    Permalink

    Same as zip but discards the output of the left hand side.

    Same as zip but discards the output of the left hand side.

    E1

    error type

    B

    type of the fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, B] combined fiber

  4. final def <*[E1 >: E, B](that: Fiber[E1, B]): Fiber[E1, A]

    Permalink

    Same as zip but discards the output of the right hand side.

    Same as zip but discards the output of the right hand side.

    E1

    error type

    B

    type of the fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, A] combined fiber

  5. final def <*>[E1 >: E, B](that: ⇒ Fiber[E1, B]): Fiber[E1, (A, B)]

    Permalink

    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.

    E1

    error type

    B

    type of that fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, (A, B)] combined fiber

  6. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  7. final def as[B](b: ⇒ B): Fiber[E, B]

    Permalink

    Maps the output of this fiber to the specified constant.

    Maps the output of this fiber to the specified constant.

    B

    type of the fiber

    b

    constant

    returns

    Fiber[E, B] fiber mapped to constant

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def dump: UIO[Option[Dump]]

    Permalink

    Generates a fiber dump, if the fiber is not synthetic.

  11. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  16. final def interrupt: UIO[Exit[E, A]]

    Permalink

    Interrupts the fiber from whichever fiber is calling this method.

    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.

    returns

    UIO[Exit, E, A]]

  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. final def join: IO[E, A]

    Permalink

    Joins the fiber, which suspends the joining fiber until the result of the fiber has been determined.

    Joins the fiber, which suspends the joining fiber until the result of the fiber has been determined. Attempting to join a fiber that has errored 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 catched and recovered.

    returns

    IO[E, A]

  19. final def map[B](f: (A) ⇒ B): Fiber[E, B]

    Permalink

    Maps over the value the Fiber computes.

    Maps over the value the Fiber computes.

    B

    result type of f

    f

    mapping function

    returns

    Fiber[E, B] mapped fiber

  20. final def mapFiber[E1 >: E, B](f: (A) ⇒ Fiber[E1, B]): UIO[Fiber[E1, B]]

    Permalink

    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.

    B

    The success value.

    f

    The callback.

    returns

    Fiber[E, B] The continued fiber.

  21. final def mapM[E1 >: E, B](f: (A) ⇒ IO[E1, B]): Fiber[E1, B]

    Permalink

    Effectually maps over the value the fiber computes.

  22. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  25. def orElse[E1 >: E, A1 >: A](that: ⇒ Fiber[E1, A1]): Fiber[E1, A1]

    Permalink

    Returns a fiber that prefers this fiber, but falls back to the that one when this one fails.

    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.

    E1

    error type

    A1

    type of the other fiber

    that

    fiber to fall back to

    returns

    Fiber[E1, A1]

  26. def orElseEither[E1 >: E, B](that: Fiber[E1, B]): Fiber[E1, Either[A, B]]

    Permalink

    Returns a fiber that prefers this fiber, but falls back to the that one when this one fails.

    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.

    E1

    error type

    B

    type of the other fiber

    that

    fiber to fall back to

    returns

    Fiber[E1, B]

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

    Permalink
    Definition Classes
    AnyRef
  28. final def toFuture(implicit ev: <:<[E, Throwable]): UIO[CancelableFuture[E, A]]

    Permalink

    Converts this fiber into a scala.concurrent.Future.

    Converts this fiber into a scala.concurrent.Future.

    ev

    implicit witness that E is a subtype of Throwable

    returns

    UIO[Future[A]]

  29. final def toFutureWith(f: (E) ⇒ Throwable): UIO[CancelableFuture[E, A]]

    Permalink

    Converts this fiber into a scala.concurrent.Future, translating any errors to java.lang.Throwable with the specified conversion function.

    Converts this fiber into a scala.concurrent.Future, translating any errors to java.lang.Throwable with the specified conversion function.

    f

    function to the error into a Throwable

    returns

    UIO[Future[A]]

  30. final def toManaged: ZManaged[Any, Nothing, Fiber[E, A]]

    Permalink

    Converts this fiber into a zio.ZManaged.

    Converts this fiber into a zio.ZManaged. Fiber is interrupted on release.

    returns

    ZManaged[Any, Nothing, Fiber[E, A]]

  31. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  32. final def unit: Fiber[E, Unit]

    Permalink

    Maps the output of this fiber to ().

    Maps the output of this fiber to ().

    returns

    Fiber[E, Unit] fiber mapped to ()

  33. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def zip[E1 >: E, B](that: ⇒ Fiber[E1, B]): Fiber[E1, (A, B)]

    Permalink

    Named alias for <*>.

    Named alias for <*>.

    E1

    error type

    B

    type of that fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, (A, B)] combined fiber

  37. final def zipLeft[E1 >: E, B](that: Fiber[E1, B]): Fiber[E1, A]

    Permalink

    Named alias for <*.

    Named alias for <*.

    E1

    error type

    B

    type of the fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, A] combined fiber

  38. final def zipRight[E1 >: E, B](that: Fiber[E1, B]): Fiber[E1, B]

    Permalink

    Named alias for *>.

    Named alias for *>.

    E1

    error type

    B

    type of the fiber

    that

    fiber to be zipped

    returns

    Fiber[E1, B] combined fiber

  39. final def zipWith[E1 >: E, B, C](that: ⇒ Fiber[E1, B])(f: (A, B) ⇒ C): Fiber[E1, C]

    Permalink

    Zips this fiber with the specified fiber, combining their results using the specified combiner function.

    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.

    E1

    error type

    B

    type of that fiber

    C

    type of the resulting fiber

    that

    fiber to be zipped

    f

    function to combine the results of both fibers

    returns

    Fiber[E1, C] combined fiber

Deprecated Value Members

  1. final def const[B](b: ⇒ B): Fiber[E, B]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0) use as

  2. final def inheritFiberRefs: UIO[Unit]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version Use inheritRefs instead) 1.0.0

  3. final def void: Fiber[E, Unit]

    Permalink

    Maps the output of this fiber to ().

    Maps the output of this fiber to ().

    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0) use unit

Inherited from AnyRef

Inherited from Any

Ungrouped