View Source Tarearbol.Pool (tarearbol v1.12.0)
The pool of workers built on top of Tarearbol.DynamicManager.
Configuration options:
pool_sizethe size of the pool, default:5payloadthe default payload for all the workers (for more complex initialization, useinitoption below)initcustominitstep as described inTarearbol.DynamicManagerdocs
This module exports defsynch/2 and defasynch/2 macros allowing to to declare
functions that would be managed by a pool behind. Basically, the below would be translated
into a message passed to the free worker of the pool.
defsynch synch(n) do
{:ok, payload!() + n}
endBoth macros have three predefined functions declared inside a block
id!returning theidof the worker invokedpayload!returning thepayloadof the worker invokedstate!returning thestateof the worker invoked as a tuple{id, payload}
Summary
Functions
Declares an asynchronous function with the same name and block, that will be under the hood
routed to the free worker to execute. If there is no free worker at the moment,
returns :error otherwise returns {:ok, result} tuple.
Declares a synchronous function with the same name and block, that will be under the hood
routed to the free worker to execute. If there is no free worker at the moment,
returns :error otherwise returns {:ok, result} tuple.
Functions
Declares an asynchronous function with the same name and block, that will be under the hood
routed to the free worker to execute. If there is no free worker at the moment,
returns :error otherwise returns {:ok, result} tuple.
This function might return any response recognizable by Tarearbol.DynamicManager.response/0.
Declares a synchronous function with the same name and block, that will be under the hood
routed to the free worker to execute. If there is no free worker at the moment,
returns :error otherwise returns {:ok, result} tuple.
This function might return any response recognizable by Tarearbol.DynamicManager.response/0.