Scope

zio.Scope
See theScope companion object
trait Scope extends Serializable

A Scope is the foundation of safe, composable resource management in ZIO. A scope has two fundamental operators, addFinalizer, which adds a finalizer to the scope, and close, which closes a scope and runs all finalizers that have been added to the scope.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait Closeable
Self type

Members list

Value members

Abstract methods

def addFinalizerExit(finalizer: Exit[Any, Any] => UIO[Any])(implicit trace: Trace): UIO[Unit]

Adds a finalizer to this scope. The finalizer is guaranteed to be run when the scope is closed.

Adds a finalizer to this scope. The finalizer is guaranteed to be run when the scope is closed.

Attributes

def forkWith(executionStrategy: => ExecutionStrategy)(implicit trace: Trace): UIO[Closeable]

Forks a new scope that is a child of this scope. Finalizers added to the child scope will be run according to the specified ExecutionStrategy. The child scope will automatically be closed when this scope is closed.

Forks a new scope that is a child of this scope. Finalizers added to the child scope will be run according to the specified ExecutionStrategy. The child scope will automatically be closed when this scope is closed.

Attributes

Concrete methods

final def addFinalizer(finalizer: => UIO[Any])(implicit trace: Trace): UIO[Unit]

A simplified version of addFinalizerWith when the finalizer does not depend on the Exit value that the scope is closed with.

A simplified version of addFinalizerWith when the finalizer does not depend on the Exit value that the scope is closed with.

Attributes

The execution strategy finalizers associated with this scope will be run with.

The execution strategy finalizers associated with this scope will be run with.

Attributes

final def extend[R]: ExtendPartiallyApplied[R]

Extends the scope of a ZIO workflow that needs a scope into this scope by providing it to the workflow but not closing the scope when the workflow completes execution. This allows extending a scoped value into a larger scope.

Extends the scope of a ZIO workflow that needs a scope into this scope by providing it to the workflow but not closing the scope when the workflow completes execution. This allows extending a scoped value into a larger scope.

Attributes

final def fork(implicit trace: Trace): UIO[Closeable]

Forks a new scope that is a child of this scope. Finalizers added to this scope will be run sequentially in the reverse of the order in which they were added when this scope is closed. The child scope will automatically be closed when this scope is closed.

Forks a new scope that is a child of this scope. Finalizers added to this scope will be run sequentially in the reverse of the order in which they were added when this scope is closed. The child scope will automatically be closed when this scope is closed.

Attributes