Module wpool_pool

A pool of workers.

Behaviours: supervisor.

Authors: Fernando Benavides (elbrujohalcon@inaka.net).

Description

A pool of workers. If you want to put it in your supervisor tree, remember it's a supervisor.

Function Index

best_worker/1Picks the worker with the smaller queue of messages.
call_available_worker/3Picks the first available worker and sends the call to it.
cast_to_available_worker/2Casts a message to the first available worker.
create_table/0Creates the ets table that will hold the information about active pools.
hash_worker/2Picks a worker base on a hash result.
next_worker/1Picks the next worker in a round robin fashion.
random_worker/1Picks a random worker.
start_link/2Starts a supervisor with several wpool_processes as its children.
stats/1Retrieves a snapshot of the pool stats.
worker_names/1Returns the names of the workers in the pool.
wpool_size/1the number of workers in the pool.

Function Details

best_worker/1

best_worker(Sup::wpool:name()) -> atom()

throws no_workers

Picks the worker with the smaller queue of messages.

call_available_worker/3

call_available_worker(Sup::wpool:name(), Call::any(), Timeout::timeout()) -> any()

throws no_workers | timeout

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.

cast_to_available_worker/2

cast_to_available_worker(Sup::wpool:name(), Cast::term()) -> ok

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

create_table/0

create_table() -> ok

Creates the ets table that will hold the information about active pools

hash_worker/2

hash_worker(Sup::wpool:name(), HashKey::term()) -> atom()

throws no_workers

Picks a worker base on a hash result.

phash2(Term, Range)
returns hash = integer, 0 <= hash < Range so
1
must be added

next_worker/1

next_worker(Sup::wpool:name()) -> atom()

throws no_workers

Picks the next worker in a round robin fashion

random_worker/1

random_worker(Sup::wpool:name()) -> atom()

throws no_workers

Picks a random worker

start_link/2

start_link(Name::wpool:name(), Options::[wpool:option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}

Starts a supervisor with several wpool_processes as its children

stats/1

stats(Sup::wpool:name()) -> wpool:stats()

throws no_workers

Retrieves a snapshot of the pool stats

worker_names/1

worker_names(Pool_Name::wpool:name()) -> [atom()]

Returns the names of the workers in the pool

wpool_size/1

wpool_size(Name::atom()) -> non_neg_integer() | undefined

the number of workers in the pool


Generated by EDoc, Dec 5 2015, 13:39:11.