Core LibraryunreleasedAPI Reference

Choose documentation 1

latest

Current version

latest
English

Unreleased libtmux_erlang has not been released. Its API may change during development. This site's structure and URLs may change too.

module libtmux-erlang latest

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

Description#

Use run/2 around a resource whose handle remains in the caller's scope. Use run_or_error/2 for nested scopes or fail-fast programs that need the callback's value directly and raise when cleanup fails. tmux_server:with_server/2 and tmux_server:with_owned/2 also 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 in failure/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.

Esc

Type to search.

Reference previewOpen reference