wpool_pool

A pool of workers.

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

Types


    

wpool() =
            #wpool{name = wpool:name(),
                   size = integer() >= 1,
                   next = integer() >= 1,
                   opts = [wpool:option()],
                   qmanager = wpool_queue_manager:queue_mgr(),
                   born = erlang:timestamp()}

Functions


create_table() -> ok

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

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

Starts a supervisor with several wpool_processes as its children

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

Picks the worker with the smaller queue of messages.

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

Picks a random worker

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

Picks the next worker in a round robin fashion

next_available_worker(Sup::name() (see module wpool)) -> atom()

Picks the first available worker, if any

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

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.

sync_send_event_to_available_worker(Sup::name() (see module wpool), Event::any(), Timeout::timeout()) -> any()

Picks the first available worker and sends the event to it.        The timeout provided includes the time it takes to get a worker        and for it to process the call.

sync_send_all_event_to_available_worker(Sup::name() (see module wpool), Event::any(), Timeout::timeout()) -> any()

Picks the first available worker and sends the event to it.        The timeout provided includes the time it takes to get a worker        and for it to process the call.

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

Picks a worker base on a hash result.        

phash2(Term, Range)

 returns hash = integer,        0 <= hash < Range so 

1

 must be added

cast_to_available_worker(Sup::name() (see module wpool), 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

send_event_to_available_worker(Sup::name() (see module wpool), Event::term()) -> ok

Sends an event to the first available worker.        Since we can wait forever for a wpool:send_event to be delivered        but we don't want the caller to be blocked, this function        just forwards the event when it gets the worker

send_all_event_to_available_worker(Sup::name() (see module wpool), Event::term()) -> ok

Sends an event to the first available worker.        Since we can wait forever for a wpool:send_event to be delivered        but we don't want the caller to be blocked, this function        just forwards the event when it gets the worker

all() -> [name() (see module wpool)]

 

stats() -> [stats() (see module wpool)]

Retrieves the pool stats for all pools

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

Retrieves a snapshot of the pool stats

next(Next::pos_integer(), WPool::wpool()) -> wpool()

Set next within the worker pool record. Useful when using   a custom strategy function.

wpool_get(List::atom(), WPool::wpool()) -> any()

Get values from the worker pool record. Useful when using a custom   strategy function.

find_wpool(Name::atom()) -> undefined | wpool()

Use this function to get the Worker pool record in a custom worker.

Fernando Benavides elbrujohalcon@inaka.net