Controller-aware Agent -- mirrors the OTP Agent API but every
get/update/cast/get_and_update is a Lockstep.GenServer.call
(or cast) and therefore a sync point.
Without this wrapper, Agent.get/3-4 etc. go through vanilla
:gen_server.call, bypassing Lockstep's controller. That hides
any race between an Agent.get (when the user does work
outside the agent based on the value, then calls back in) and
a concurrent Agent.update.
A typical example: an LRU cache that does :ets.lookup directly
then calls Agent.get(...) -- a delete in between corrupts the
LRU's TTL table. Lockstep can find that race only if both the ETS
calls AND the Agent calls are sync points.
Summary
Functions
Fire-and-forget update.
Apply fun to the agent's state and return the result.
Apply module.fun([state | args]) and return the result.
Atomically get and update via fun.(state) -> {result, new_state}.
Unlinked variant of start_link/1.
Start an agent linked to the calling process. fun is invoked
to produce the initial state.
Start an agent with options (name: for atom registration).
Start an agent invoking apply(module, fun, args) to produce
initial state.
Stop the agent.
Update the state via fun.(state).
Update via module.fun([state | args]).
Functions
Fire-and-forget update.
Apply fun to the agent's state and return the result.
Apply module.fun([state | args]) and return the result.
Atomically get and update via fun.(state) -> {result, new_state}.
Unlinked variant of start_link/1.
Start an agent linked to the calling process. fun is invoked
to produce the initial state.
Start an agent with options (name: for atom registration).
Start an agent invoking apply(module, fun, args) to produce
initial state.
Stop the agent.
Update the state via fun.(state).
Update via module.fun([state | args]).