View Source wpool_pool (worker_pool v6.1.0)
Link to this section Summary
Functions
Adds a callback module. The module must implement the
wpool_process_callbacksbehaviour.Picks the worker with the smaller queue of messages.
Casts a message to all the workers within the given pool.
Picks the first available worker and sends the call to it. The timeout provided includes the time it takes to get a worker and for it to process the call.
Casts a message to the first available worker. Since we can wait forever for a wpool:cast to be delivered but we don't want the caller to be blocked, this function just forwards the cast when it gets the worker
Use this function to get the Worker pool record in a custom worker.
Retrieves the list of worker registered names. This can be useful to manually inspect the workers or do custom work on them.
Picks a worker base on a hash result.
phash2(Term, Range)returns hash = integer, 0 <= hash < Range so1must be addedSet next within the worker pool record. Useful when using a custom strategy function.
Picks the first available worker, if any
Picks the next worker in a round robin fashion
Picks a random worker
Removes a callback module.
Picks the first available worker and sends the request to it. The timeout provided considers only the time it takes to get a worker
Starts a supervisor with several
wpool_processes as its childrenRetrieves the pool stats for all pools
Retrieves a snapshot of the pool stats
Get values from the worker pool record. Useful when using a custom strategy function.
Link to this section Types
-opaque wpool()
Link to this section Functions
-spec add_callback_module(wpool:name(), module()) -> ok | {error, term()}.
wpool_process_callbacksbehaviour.
-spec best_worker(wpool:name()) -> atom().
-spec broadcast(wpool:name(), term()) -> ok.
-spec call_available_worker(wpool:name(), any(), timeout()) -> atom().
-spec cast_to_available_worker(wpool:name(), term()) -> ok.
-spec find_wpool(atom()) -> undefined | wpool().
-spec get_workers(wpool:name()) -> [atom()].
-spec hash_worker(wpool:name(), term()) -> atom().
phash2(Term, Range)returns hash = integer, 0 <= hash < Range so1must be added
-spec next_available_worker(wpool:name()) -> atom().
-spec next_worker(wpool:name()) -> atom().
-spec random_worker(wpool:name()) -> atom().
-spec remove_callback_module(wpool:name(), module()) -> ok | {error, term()}.
-spec send_request_available_worker(wpool:name(), any(), timeout()) -> noproc | timeout | gen_server:request_id().
-spec start_link(wpool:name(), [wpool:option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}.
wpool_processes as its children
-spec stats() -> [wpool:stats()].
-spec stats(wpool:name()) -> wpool:stats().
-spec worker_name(wpool:name(), pos_integer()) -> atom().