View Source Tarearbol.Pool (tarearbol v1.12.0)
The pool of workers built on top of Tarearbol.DynamicManager
.
Configuration options:
pool_size
the size of the pool, default:5
payload
the default payload for all the workers (for more complex initialization, useinit
option below)init
custominit
step as described inTarearbol.DynamicManager
docs
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}
end
Both macros have three predefined functions declared inside a block
id!
returning theid
of the worker invokedpayload!
returning thepayload
of the worker invokedstate!
returning thestate
of 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
.