clojerl.Agent
Clojure Agent.
Summary
Types
Functions
-
dispatch(Agent, Fun, Args)
Dispatch an action to an agent.
-
error(Agent)
Returns the error thrown during an asynchronous action of the agent if the agent is failed.
-
error_handler(Agent)
Returns the error-handler of
Agent
, orundefined
if there is none. -
error_handler(Agent, ErrorHandler)
Sets the error-handler of
Agent
a toErrorHandler
. -
error_mode(Agent)
Returns the error-mode of
Agent
. -
error_mode(Agent, ErrorMode)
Sets the error-mode of
Agent
a toErrorMode
, which must be eitherfail
orcontinue
. -
release_pending_sends()
Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state).
-
restart(Agent, NewValue, ClearActions)
When an agent is failed, changes the agent state to new-state and then un-fails the agent so that sends are allowed again.
-
validator(Agent)
Gets the validator function for the
Agent
. -
validator(Agent, Validator)
Sets the validator function for the
Agent
.
Types
type()
-type type() ::
#{'__type__' => 'clojerl.Agent', id => binary(), pid => pid()}.
Functions
dispatch(Agent, Fun, Args)
-spec dispatch(type(), any(), any()) -> type().
Dispatch an action to an agent.
error(Agent)
-spec error(type()) -> any().
Returns the error thrown during an asynchronous action of the
agent if the agent is failed. Returns undefined
if the agent is
not failed.
error_handler(Agent)
-spec error_handler(type()) -> function().
Returns the error-handler of Agent
, or undefined
if there
is none.
error_handler(Agent, ErrorHandler)
-spec error_handler(type(), function()) -> any().
Sets the error-handler of Agent
a to ErrorHandler
.
error_mode(Agent)
-spec error_mode(type()) -> atom().
Returns the error-mode of Agent
.
error_mode(Agent, ErrorMode)
-spec error_mode(type(), fail | continue) -> any().
Sets the error-mode of Agent
a to ErrorMode
, which must be
either fail
or continue
.
release_pending_sends()
-spec release_pending_sends() -> non_neg_integer().
Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent actions immediately. If no action is occurring, does nothing. Returns the number of actions dispatched.
restart(Agent, NewValue, ClearActions)
-spec restart(type(), any(), boolean()) -> any().
When an agent is failed, changes the agent state to new-state and then un-fails the agent so that sends are allowed again.
validator(Agent)
-spec validator(type()) -> any().
Gets the validator function for the Agent
.
validator(Agent, Validator)
-spec validator(type(), function()) -> any().
Sets the validator function for the Agent
.