Module wpool

Worker pool main interface.

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

Description

Worker pool main interface. Use functions provided by this module to manage your pools of workers

Data Types

custom_strategy()

custom_strategy() = fun(([atom()]) -> Atom::atom())

debug_flag()

debug_flag() = trace | log | statistics | debug | {logfile, string()}

gen_option()

gen_option() = {timeout, timeout()} | {debug, [debug_flag()]} | {spawn_opt, [proc_lib:spawn_option()]}

gen_options()

gen_options() = [gen_option()]

name()

name() = atom()

option()

option() = {overrun_warning, infinity | pos_integer()} | {overrun_handler, {Module::atom(), Fun::atom()}} | {workers, pos_integer()} | {worker_opt, gen_options()} | {worker, {Module::atom(), InitArg::term()}} | {strategy, supervisor_strategy()} | {worker_type, gen_fsm | gen_server} | {pool_sup_intensity, non_neg_integer()} | {pool_sup_period, non_neg_integer()}

stats()

stats() = [{pool, name()} | {supervisor, pid()} | {options, [option()]} | {size, non_neg_integer()} | {next_worker, pos_integer()} | {total_message_queue_len, non_neg_integer()} | {workers, [{pos_integer(), worker_stats()}]}]

strategy()

strategy() = best_worker | random_worker | next_worker | available_worker | next_available_worker | {hash_worker, term()} | custom_strategy()

supervisor_strategy()

supervisor_strategy() = {supervisor:strategy(), non_neg_integer(), pos_integer()}

worker_stats()

worker_stats() = [{messsage_queue_len, non_neg_integer()} | {memory, pos_integer()}]

Function Index

call/2Equivalent to call(Sup, Call, default_strategy()).
call/3Equivalent to call(Sup, Call, Strategy, 5000).
call/4Picks a server and issues the call to it.
cast/2Equivalent to cast(Sup, Cast, default_strategy()).
cast/3Picks a server and issues the cast to it.
default_strategy/0Default strategy.
send_all_state_event/2Equivalent to send_all_state_event(Sup, Event, default_strategy()).
send_all_state_event/3Picks a server and issues the event to it.
send_event/2Equivalent to send_event(Sup, Event, default_strategy()).
send_event/3Picks a server and issues the event to it.
start/0Starts the application.
start_pool/1Equivalent to start_pool(Name, []).
start_pool/2Starts (and links) a pool of N wpool_processes.
start_sup_pool/1Equivalent to start_sup_pool(Name, []).
start_sup_pool/2Starts a pool of N wpool_processes supervised by wpool_sup
stats/0Retrieves a snapshot of the pool stats.
stats/1Retrieves a snapshot of a given pool stats.
stop/0Stops the application.
stop_pool/1Stops the pool.
sync_send_all_state_event/2Equivalent to sync_send_all_state_event(Sup, Event, default_strategy()).
sync_send_all_state_event/3Equivalent to sync_send_all_state_event(Sup, Event, Strategy, 5000).
sync_send_all_state_event/4Picks a fsm and issues the event to it.
sync_send_event/2Equivalent to sync_send_event(Sup, Event, default_strategy()).
sync_send_event/3Equivalent to sync_send_event(Sup, Event, Strategy, 5000).
sync_send_event/4Picks a fsm and issues the event to it.

Function Details

call/2

call(Sup::name(), Call::term()) -> term()

Equivalent to call(Sup, Call, default_strategy()).

call/3

call(Sup::name(), Call::term(), Strategy::strategy()) -> term()

Equivalent to call(Sup, Call, Strategy, 5000).

call/4

call(Sup::name(), Call::term(), Fun::strategy(), Timeout::timeout()) -> term()

Picks a server and issues the call to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered

cast/2

cast(Sup::name(), Cast::term()) -> ok

Equivalent to cast(Sup, Cast, default_strategy()).

cast/3

cast(Sup::name(), Cast::term(), Fun::strategy()) -> ok

Picks a server and issues the cast to it

default_strategy/0

default_strategy() -> strategy()

Default strategy

send_all_state_event/2

send_all_state_event(Sup::name(), Event::term()) -> ok

Equivalent to send_all_state_event(Sup, Event, default_strategy()).

send_all_state_event/3

send_all_state_event(Sup::name(), Event::term(), Fun::strategy()) -> ok

Picks a server and issues the event to it

send_event/2

send_event(Sup::name(), Event::term()) -> ok

Equivalent to send_event(Sup, Event, default_strategy()).

send_event/3

send_event(Sup::name(), Event::term(), Fun::strategy()) -> ok

Picks a server and issues the event to it

start/0

start() -> ok | {error, {already_started, '?MODULE'}}

Starts the application

start_pool/1

start_pool(Name::name()) -> {ok, pid()}

Equivalent to start_pool(Name, []).

start_pool/2

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

Starts (and links) a pool of N wpool_processes. The result pid belongs to a supervisor (in case you want to add it to a supervisor tree)

start_sup_pool/1

start_sup_pool(Name::name()) -> {ok, pid()}

Equivalent to start_sup_pool(Name, []).

start_sup_pool/2

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

Starts a pool of N wpool_processes supervised by wpool_sup

stats/0

stats() -> [stats()]

Retrieves a snapshot of the pool stats

stats/1

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

Retrieves a snapshot of a given pool stats

stop/0

stop() -> ok

Stops the application

stop_pool/1

stop_pool(Name::name()) -> ok

Stops the pool

sync_send_all_state_event/2

sync_send_all_state_event(Sup::name(), Event::term()) -> term()

Equivalent to sync_send_all_state_event(Sup, Event, default_strategy()).

sync_send_all_state_event/3

sync_send_all_state_event(Sup::name(), Event::term(), Strategy::strategy()) -> term()

Equivalent to sync_send_all_state_event(Sup, Event, Strategy, 5000).

sync_send_all_state_event/4

sync_send_all_state_event(Sup::name(), Event::term(), Fun::strategy(), Timeout::timeout()) -> term()

Picks a fsm and issues the event to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered

sync_send_event/2

sync_send_event(Sup::name(), Event::term()) -> term()

Equivalent to sync_send_event(Sup, Event, default_strategy()).

sync_send_event/3

sync_send_event(Sup::name(), Event::term(), Strategy::strategy()) -> term()

Equivalent to sync_send_event(Sup, Event, Strategy, 5000).

sync_send_event/4

sync_send_event(Sup::name(), Event::term(), Fun::strategy(), Timeout::timeout()) -> term()

Picks a fsm and issues the event to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered


Generated by EDoc, Apr 3 2017, 11:16:15.