Frontier.Store.Owner
(Frontier v0.2.1)
Copy Markdown
Stable owner process for Frontier's ETS tables.
The tables are :named_tables, so whichever process creates them owns
them and takes them down when it exits. During compilation the creator is
a transient compiler worker — when it finishes its batch and dies, the
tables vanish and the next worker's insert crashes with "the table
identifier does not refer to an existing ETS table". This process exists
solely to be that stable owner: it creates the tables, then blocks forever
in receive, so ownership never rides on a worker's lifetime.
Started supervised at runtime (via Frontier.Application) and lazily,
unlinked and detached, at compile time (via Frontier.Store.init/0).
Summary
Functions
Ensures a single owner process is running and the tables exist.
Starts the owner linked to the caller, for supervised runtime use. A no-op that returns the existing pid if a compile-time owner already holds the name.
Functions
@spec ensure_started() :: :ok
Ensures a single owner process is running and the tables exist.
Spawns the owner unlinked (spawn/1, not spawn_link/1) so it
outlives the transient compiler worker that triggered it, and registers it
under a fixed name so concurrent callers converge on one owner. Blocks
until the tables are confirmed present, so a caller can insert immediately
on return.
@spec start_link() :: {:ok, pid()}
Starts the owner linked to the caller, for supervised runtime use. A no-op that returns the existing pid if a compile-time owner already holds the name.