Poolex.Workers.Behaviour behaviour (poolex v1.2.1)
View SourceBehaviour for worker collection implementations.
Summary
Callbacks
Adds worker's pid to state and returns new state.
Returns the number of workers in the 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.
Same as init/0 but returns state initialized with passed list of workers.
Returns true if given worker contained in the state, false otherwise.
Removes one of workers from state and returns it as {caller, state}. Returns :empty if state is empty.
Removes given worker from state and returns new state.
Returns list of workers pids.
Types
@type state() :: any()
Callbacks
@callback add(state(), Poolex.worker()) :: state()
Adds worker's pid to state and returns new state.
@callback count(state()) :: non_neg_integer()
Returns the number of workers in the 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.
Same as init/0 but returns state initialized with passed list of workers.
@callback member?(state(), Poolex.worker()) :: boolean()
Returns true if given worker contained in the state, false otherwise.
@callback pop(state()) :: {Poolex.worker(), state()} | :empty
Removes one of workers from state and returns it as {caller, state}. Returns :empty if state is empty.
@callback remove(state(), Poolex.worker()) :: state()
Removes given worker from state and returns new state.
@callback to_list(state()) :: [Poolex.worker()]
Returns list of workers pids.