tmux_scope
Run synchronous work and cleanup while preserving both outcomes.
Source and package
- Qualified name
-
tmux_scope - Package
- libtmux_erlang
- Source
- apps/libtmux_erlang/src/tmux_scope.erl
- tmux_scope
-
Description#
Use
run/2around a resource whose handle remains in the caller's scope. Userun_or_error/2for nested scopes or fail-fast programs that need the callback's value directly and raise when cleanup fails.tmux_server:with_server/2andtmux_server:with_owned/2also acquire their resources and add recovery handles when cleanup fails. This module owns no process, timeout or retry policy; the supplied functions own those contracts.
Members4#
Common operations2#
- run_or_error/2 function Run work and cleanup with
run/2, returning the callback value directly. Raises {scope_cleanup_failed, Failure} if cleanup fails, retaining both outcomes infailure/0. With successful cleanup, callback exceptions retain their original reason and stack. Nested raising scopes propagate an inner failure through the outer scope while still attempting outer cleanup. - run/2 function Run a callback, then attempt cleanup once, synchronously in the calling process. This function performs only the I/O supplied by those functions. The callback has no library duration timer. Abrupt uncatchable caller death remains subject to each resource's existing ownership policy.
Other members2#
- exception/0 typealias The original exception class, reason and stack, retained as evidence.
- failure/0 typealias Both outcomes when cleanup failed. primary contains the callback's ordinary return or exception; cleanup contains its separate error or exception. Resource-specific wrappers may add recovery handles to this map.
Guides#
Pages that discuss tmux_scope.