View Source Poolex.Callers.Behaviour behaviour (poolex v1.0.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()

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 caller by pid from state and returns new state.

Removes caller by reference from state and returns new state.

Returns list of callers.

Types

@type state() :: any()

Callbacks

@callback add(state(), Poolex.Caller.t()) :: state()

Adds caller to state and returns new state.

@callback empty?(state()) :: boolean()

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.t(), state()} | :empty

Removes one of callers from state and returns it as {caller, state}. Returns :empty if state is empty.

Link to this callback

remove_by_pid(state, caller_pid)

View Source
@callback remove_by_pid(state(), caller_pid :: pid()) :: state()

Removes caller by pid from state and returns new state.

Link to this callback

remove_by_reference(state, reference)

View Source
@callback remove_by_reference(state(), reference :: reference()) :: state()

Removes caller by reference from state and returns new state.

@callback to_list(state()) :: [Poolex.Caller.t()]

Returns list of callers.