A FinalizerRef
describes the finalizers associated with a scope.
Submerges the error case of an Either
into the ZManaged
.
Submerges the error case of an Either
into the ZManaged
. The inverse
operation of ZManaged.either
.
Create a managed that accesses the environment.
Create a managed that accesses the environment.
Create a managed that accesses the environment.
Creates new ZManaged from wrapped Reservation.
Evaluate each effect in the structure from left to right, and collect the results.
Evaluate each effect in the structure from left to right, and collect
the results. For a parallel version, see collectAllPar
.
Evaluate each effect in the structure in parallel, and collect the results.
Evaluate each effect in the structure in parallel, and collect
the results. For a sequential version, see collectAll
.
Evaluate each effect in the structure in parallel, and collect the results.
Evaluate each effect in the structure in parallel, and collect
the results. For a sequential version, see collectAll
.
Unlike CollectAllPar
, this method will use at most n
fibers.
Returns an effect that dies with the specified Throwable
.
Returns an effect that dies with the specified Throwable
.
This method can be used for terminating a fiber because a defect has been
detected in the code.
Returns an effect that dies with a java.lang.RuntimeException having the specified text message.
Returns an effect that dies with a java.lang.RuntimeException having the specified text message. This method can be used for terminating a fiber because a defect has been detected in the code.
Returns an effect from a lazily evaluated zio.Exit value.
Lifts a by-name, pure value into a Managed.
Accesses the whole environment of the effect.
Returns an effect that models failure with the specified error.
Returns an effect that models failure with the specified error.
The moral equivalent of throw
for pure code.
Returns an effect that succeeds with the Fiber.Id
of the caller.
Creates an effect that only executes the provided finalizer as its release action.
Creates an effect that only executes the provided function as its release action.
Creates an effect that executes a finalizer stored in a FinalizerRef.
Creates an effect that executes a finalizer stored in a FinalizerRef.
The FinalizerRef
is yielded as the result of the effect, allowing for
control flows that require mutating finalizers.
Returns an effectful function that extracts out the first element of a tuple.
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
This method can be used to "flatten" nested effects.
Applies the function f
if the argument is non-empty and
returns the results in a new Option[A2]
.
Applies the function f
to each element of the Iterable[A]
and
returns the results in a new List[B]
.
Applies the function f
to each element of the Iterable[A]
and
returns the results in a new List[B]
.
For a parallel version of this method, see foreachPar
.
Applies the function f
to each element of the Iterable[A]
in parallel,
and returns the results in a new List[B]
.
Applies the function f
to each element of the Iterable[A]
in parallel,
and returns the results in a new List[B]
.
For a sequential version of this method, see foreach
.
Applies the function f
to each element of the Iterable[A]
in parallel,
and returns the results in a new List[B]
.
Applies the function f
to each element of the Iterable[A]
in parallel,
and returns the results in a new List[B]
.
Unlike foreachPar
, this method will use at most up to n
fibers.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects in parallel, discarding the results.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects in parallel, discarding the results.
Unlike foreachPar_
, this method will use at most up to n
fibers.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects in parallel, discarding the results.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects in parallel, discarding the results.
For a sequential version of this method, see foreach_
.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects sequentially.
Applies the function f
to each element of the Iterable[A]
and runs
produced effects sequentially.
Equivalent to foreach(as)(f).unit
, but without the cost of building
the list of results.
Creates a ZManaged from an AutoCloseable
resource.
Creates a ZManaged from an AutoCloseable
resource. The resource's close
method will be used as the release action.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with no release action.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with no release action. The effect will be performed interruptibly.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with no release action.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with no release action. The effect will be performed uninterruptibly. You usually want the ZManaged.fromEffect variant.
Lifts an Either
into a ZManaged
value.
Lifts a function R => A
into a ZManaged[R, Nothing, A]
.
Lifts an effectful function whose effect requires no environment into an effect that requires the input to the function.
Returns an effect that models failure with the specified Cause
.
Returns the identity effectful function, which performs no effects
Runs onTrue
if the result of b
is true
and onFalse
otherwise.
Returns an effect that is interrupted as if by the fiber calling this method.
Returns an effect that is interrupted as if by the specified fiber.
Iterates with the specified effectual function.
Iterates with the specified effectual function. The moral equivalent of:
var s = initial while (cont(s)) { s = body(s) } s
Loops with the specified effectual function, collecting the results into a list.
Loops with the specified effectual function, collecting the results into a list. The moral equivalent of:
var s = initial var as = List.empty[A] while (cont(s)) { as = body(s) :: as s = inc(s) } as.reverse
Loops with the specified effectual function purely for its effects.
Loops with the specified effectual function purely for its effects. The moral equivalent of:
var s = initial while (cont(s)) { body(s) s = inc(s) }
Lifts a ZIO[R, E, A]
into ZManaged[R, E, A]
with a release action.
Lifts a ZIO[R, E, A]
into ZManaged[R, E, A]
with a release action.
The acquire and release actions will be performed uninterruptibly.
Lifts a synchronous effect into ZManaged[R, Throwable, A]
with a release action.
Lifts a synchronous effect into ZManaged[R, Throwable, A]
with a release action.
The acquire and release actions will be performed uninterruptibly.
Lifts a ZIO[R, E, A]
into ZManaged[R, E, A]
with a release action that handles Exit
.
Lifts a ZIO[R, E, A]
into ZManaged[R, E, A]
with a release action that handles Exit
.
The acquire and release actions will be performed uninterruptibly.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with a release action.
Lifts a ZIO[R, E, A] into ZManaged[R, E, A] with a release action. The acquire action will be performed interruptibly, while release will be performed uninterruptibly.
Sequentially zips the specified effects using the specified combiner function.
Sequentially zips the specified effects using the specified combiner function.
Sequentially zips the specified effects using the specified combiner function.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function. If any effect
fails, then the other effects will be interrupted.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function. If any effect
fails, then the other effects will be interrupted.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function.
Returns an effect that executes the specified effects in parallel,
combining their results with the specified f
function. If any effect
fails, then the other effects will be interrupted.
Merges an Iterable[IO]
to a single IO, working sequentially.
Merges an Iterable[IO]
to a single IO, working in parallel.
Merges an Iterable[IO]
to a single IO, working in parallel.
Merges an Iterable[IO]
to a single IO, working in parallel.
Unlike mergeAllPar
, this method will use at most up to n
fibers.
This is not implemented in terms of ZIO.foreach / ZManaged.zipWithPar as otherwise all reservation phases would always run, causing unnecessary work
Returns a ZManaged
that never acquires a resource.
Creates a scope in which resources can be safely preallocated.
Reduces an Iterable[IO]
to a single IO
, working sequentially.
Reduces an Iterable[IO]
to a single IO
, working in parallel.
Reduces an Iterable[IO]
to a single IO
, working in parallel.
Reduces an Iterable[IO]
to a single IO
, working in parallel.
Unlike mergeAllPar
, this method will use at most up to n
fibers.
This is not implemented in terms of ZIO.foreach / ZManaged.zipWithPar as otherwise all reservation phases would always run, causing unnecessary work
Requires that the given ZManaged[E, Option[A]]
contain a value.
Requires that the given ZManaged[E, Option[A]]
contain a value. If there is no
value, then the specified error will be raised.
Lifts a pure Reservation[R, E, A]
into ZManaged[R, E, A]
Creates a scope in which resources can be safely allocated into together with a release action.
Returns an effectful function that extracts out the second element of a tuple.
Lifts a lazy, pure value into a Managed.
Returns a lazily constructed Managed.
Returns an effectful function that merely swaps the elements in a Tuple2
.
Returns a ZManaged value that represents a managed resource that can be safely swapped within the scope of the ZManaged.
Returns a ZManaged value that represents a managed resource that can be safely swapped within the scope of the ZManaged. The function provided inside the ZManaged can be used to switch the resource currently in use.
When the resource is switched, the finalizer for the previous finalizer will be executed uninterruptibly. If the effect executing inside the ZManaged#use is interrupted, the finalizer for the resource currently in use is guaranteed to execute.
This constructor can be used to create an expressive control flow that uses several instances of a managed resource. For example:
def makeWriter: Task[FileWriter] trait FileWriter { def write(data: Int): Task[Unit] def close: UIO[Unit] } val elements = List(1, 2, 3, 4) val writingProgram = ZManaged.switchable[Any, Throwable, FileWriter].use { switchWriter => ZIO.foreach_(elements) { element => for { writer <- switchWriter(makeWriter.toManaged(_.close)) _ <- writer.write(element) } yield () } }
Returns the effect resulting from mapping the success of this effect to unit.
The inverse operation to sandbox
.
The inverse operation to sandbox
. Submerges the full cause of failure.
Unwraps a ZManaged
that is inside a ZIO
.
The moral equivalent of if (p) exp
Runs an effect when the supplied PartialFunction
matches for the given value, otherwise does nothing.
Runs an effect when the supplied PartialFunction
matches for the given effectful value, otherwise does nothing.
The moral equivalent of if (p) exp
when p
has side-effects
Alias for ZManaged.collectAll
Alias for ZManaged.collectAll
(Since version 1.0.0) use collectAll
Alias for ZManaged.collectAllPar
Alias for ZManaged.collectAllPar
(Since version 1.0.0) use collectAllPar
Alias for ZManaged.collectAllParN
Alias for ZManaged.collectAllParN
(Since version 1.0.0) use collectAllParN
Alias for ZManaged.foreach[R,E,A1,A2](as:Iterable*
Alias for ZManaged.foreach[R,E,A1,A2](as:Iterable*
(Since version 1.0.0) use foreach
Alias for ZManaged.foreachPar
Alias for ZManaged.foreachPar
(Since version 1.0.0) use foreachPar
Alias for ZManaged.foreachParN
Alias for ZManaged.foreachParN
(Since version 1.0.0) use foreachParN
Alias for ZManaged.foreachParN_
Alias for ZManaged.foreachParN_
(Since version 1.0.0) use foreachParN_
Alias for ZManaged.foreachPar_
Alias for ZManaged.foreachPar_
(Since version 1.0.0) use foreachPar_
Alias for ZManaged.foreach_
Alias for ZManaged.foreach_
(Since version 1.0.0) use foreach_