Hourglass.Activity.CancelRegistry (hourglass v0.3.0)

Copy Markdown View Source

Per-task_token cancellation flags bridging the Cancel activity task (received by Hourglass.ActivityRunner) to the running activity's Hourglass.Activity.heartbeat/0.

Owns a single public, read_concurrency ETS table named after this module. cancelled?/1 is a lock-free direct read on the heartbeat hot path; mark/2 and clear/1 are direct ETS writes (no GenServer round-trip). The GenServer exists to own the table's lifetime and to periodically sweep leaked entries — a Cancel that arrives AFTER its Start task already completed (and cleared) would otherwise leave an entry nobody reads.

Started app-scope (always-on) by Hourglass.Application so heartbeat/0 can read it in every test lane, not only the :temporal suite.

Summary

Functions

cancelled?(task_token)

@spec cancelled?(binary()) :: term() | nil

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(task_token)

@spec clear(binary()) :: :ok

mark(task_token, reason)

@spec mark(binary(), term()) :: :ok

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()