Fiber

object Fiber
Companion:
class
class Object
trait Matchable
class Any
Fiber.type

Type members

Classlikes

final case class Descriptor(id: Runtime, status: Running, interrupters: Set[FiberId], executor: Executor, isLocked: Boolean)

A record containing information about a Fiber.

A record containing information about a Fiber.

Value parameters:
children

The fiber's forked children.

executor

The Executor executing this fiber

id

The fiber's unique identifier

interrupters

The set of fibers attempting to interrupt the fiber or its ancestors.

final case class Dump(fiberId: Runtime, status: Status, trace: StackTrace) extends Product with Serializable
sealed abstract class Runtime[+E, +A] extends Fiber[E, A]

A runtime fiber that is executing an effect. Runtime fibers have an identity and a trace.

A runtime fiber that is executing an effect. Runtime fibers have an identity and a trace.

object Status
Companion:
class
sealed trait Status
Companion:
object
sealed abstract class Synthetic[+E, +A] extends Fiber[E, A]

A synthetic fiber that is created from a pure value or that combines existing fibers.

A synthetic fiber that is created from a pure value or that combines existing fibers.

Value members

Concrete methods

def awaitAll(fs: Iterable[Fiber[Any, Any]])(implicit trace: Trace): UIO[Unit]

Awaits on all fibers to be completed, successfully or not.

Awaits on all fibers to be completed, successfully or not.

Value parameters:
fs

Iterable of fibers to be awaited

Returns:

UIO[Unit]

def collectAll[E, A, Collection <: (Iterable)](fibers: Collection[Fiber[E, A]])(implicit bf: BuildFrom[Collection[Fiber[E, A]], A, Collection[A]]): Synthetic[E, Collection[A]]

Collects all fibers into a single fiber producing an in-order list of the results.

Collects all fibers into a single fiber producing an in-order list of the results.

def currentFiber()(unsafe: Unsafe): Option[Fiber[Any, Any]]

Retrieves the fiber currently executing on this thread, if any. This will always be None unless called from within an executing effect and this feature is enabled using Runtime.enableCurrentFiber.

Retrieves the fiber currently executing on this thread, if any. This will always be None unless called from within an executing effect and this feature is enabled using Runtime.enableCurrentFiber.

def done[E, A](exit: => Exit[E, A]): Synthetic[E, A]

A fiber that is done with the specified zio.Exit value.

A fiber that is done with the specified zio.Exit value.

Type parameters:
A

type of the fiber

E

error type

Value parameters:
exit

zio.Exit value

Returns:

Fiber[E, A]

def dumpAll(implicit trace: Trace): ZIO[Any, IOException, Unit]

Dumps all fibers to the console.

Dumps all fibers to the console.

def dumpAllWith[R, E](f: Dump => ZIO[R, E, Any])(implicit trace: Trace): ZIO[R, E, Unit]

Dumps all fibers to the specified callback.

Dumps all fibers to the specified callback.

def fail[E](e: E): Synthetic[E, Nothing]

A fiber that has already failed with the specified value.

A fiber that has already failed with the specified value.

Type parameters:
E

error type

Value parameters:
e

failure value

Returns:

Fiber[E, Nothing] failed fiber

def failCause[E](cause: Cause[E]): Synthetic[E, Nothing]

Creates a Fiber that has already failed with the specified cause.

Creates a Fiber that has already failed with the specified cause.

def fromFuture[A](thunk: => Future[A])(implicit trace: Trace): Synthetic[Throwable, A]

Returns a Fiber that is backed by the specified Future.

Returns a Fiber that is backed by the specified Future.

Type parameters:
A

type of the Fiber

Value parameters:
thunk

Future[A] backing the Fiber

Returns:

Fiber[Throwable, A]

def fromZIO[E, A](io: IO[E, A])(implicit trace: Trace): UIO[Synthetic[E, A]]

Lifts an zio.ZIO into a Fiber.

Lifts an zio.ZIO into a Fiber.

Type parameters:
A

type of the fiber

E

error type

Value parameters:
io

IO[E, A] to turn into a Fiber

Returns:

UIO[Fiber[E, A]]

def interruptAll(fs: Iterable[Fiber[Any, Any]])(implicit trace: Trace): UIO[Unit]

Interrupts all fibers, awaiting their interruption.

Interrupts all fibers, awaiting their interruption.

Value parameters:
fs

Iterable of fibers to be interrupted

Returns:

UIO[Unit]

def interruptAllAs(fiberId: FiberId)(fs: Iterable[Fiber[Any, Any]])(implicit trace: Trace): UIO[Unit]

Interrupts all fibers as by the specified fiber, awaiting their interruption.

Interrupts all fibers as by the specified fiber, awaiting their interruption.

Value parameters:
fiberId

The identity of the fiber to interrupt as.

fs

Iterable of fibers to be interrupted

Returns:

UIO[Unit]

def interruptAs(id: FiberId): Synthetic[Nothing, Nothing]

A fiber that is already interrupted.

A fiber that is already interrupted.

Returns:

Fiber[Nothing, Nothing] interrupted fiber

def joinAll[E](fs: Iterable[Fiber[E, Any]])(implicit trace: Trace): IO[E, Unit]

Joins all fibers, awaiting their successful completion. Attempting to join a fiber that has erred will result in a catchable error, if that error does not result from interruption.

Joins all fibers, awaiting their successful completion. Attempting to join a fiber that has erred will result in a catchable error, if that error does not result from interruption.

Value parameters:
fs

Iterable of fibers to be joined

Returns:

UIO[Unit]

def roots(implicit trace: Trace): UIO[Chunk[Runtime[_, _]]]

Returns a chunk containing all root fibers. Due to concurrency, the returned chunk is only weakly consistent.

Returns a chunk containing all root fibers. Due to concurrency, the returned chunk is only weakly consistent.

def succeed[A](a: A): Synthetic[Nothing, A]

Returns a fiber that has already succeeded with the specified value.

Returns a fiber that has already succeeded with the specified value.

Type parameters:
A

type of the fiber

E

error type

Value parameters:
a

success value

Returns:

Fiber[E, A] succeeded fiber

Inherited methods

Inherited from:
FiberPlatformSpecific
def fromFutureJava[A](thunk: => Future[A]): Fiber[Throwable, A]

WARNING: this uses the blocking Future#get, consider using fromCompletionStage

WARNING: this uses the blocking Future#get, consider using fromCompletionStage

Inherited from:
FiberPlatformSpecific

Concrete fields

val never: Synthetic[Nothing, Nothing]

A fiber that never fails or succeeds.

A fiber that never fails or succeeds.

val unit: Synthetic[Nothing, Unit]

A fiber that has already succeeded with unit.

A fiber that has already succeeded with unit.