View Source Poolex.Callers.Behaviour behaviour (poolex v0.7.0)
Behaviour for callers collection implementations.
caller is a process that uses the Poolex.run/3 function and waits for the execution result.
Note that the caller's typespec matches GenServer.from()
Link to this section Summary
Callbacks
Adds caller to state and returns new state.
Returns true if the state is empty, false otherwise.
Returns state (any data structure) which will be passed as the first argument to all other functions.
Removes one of callers from state and returns it as {caller, state}. Returns :empty if state is empty.
Removes given caller by caller's pid from state and returns new state.
Returns list of callers.
Link to this section Types
@type state() :: any()
Link to this section Callbacks
@callback add(state(), Poolex.caller()) :: state()
Adds caller to state and returns new state.
Returns true if the state is empty, false otherwise.
@callback init() :: state()
Returns state (any data structure) which will be passed as the first argument to all other functions.
@callback pop(state()) :: {Poolex.caller(), state()} | :empty
Removes one of callers from state and returns it as {caller, state}. Returns :empty if state is empty.
Removes given caller by caller's pid from state and returns new state.
@callback to_list(state()) :: [Poolex.caller()]
Returns list of callers.