Box.PoolProcessor (box v0.15.1)

View Source

Starts a pool processor that runs jobs concurrently

Examples

iex> Box.PoolProcessor.start_link(name: MyPool, size: 10)
{:ok, pid}

iex> Box.PoolProcessor.async(MyPool, fn -> IO.inspect("Hello") end)
:ok

Summary

Functions

Enqueues a function call in the pool asynchronously

Returns a specification to start this module under a supervisor.

Starts a child in the pool supervisor

Starts a pool supervisor

Enqueues a function call and awaits for it to be completed.

Types

execute_function()

@type execute_function() :: function() | mfa()

option()

@type option() :: {:size, non_neg_integer()}

pool_supervisor()

@type pool_supervisor() :: atom() | pid()

Functions

async(pool, function)

@spec async(pool_supervisor(), execute_function()) :: :ok

Enqueues a function call in the pool asynchronously

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

spawn_process(function)

start_child(pool, function)

@spec start_child(pool_supervisor(), execute_function()) :: {:ok, pid()}

Starts a child in the pool supervisor

start_link(args)

@spec start_link([option()]) :: Supervisor.on_start_child()

Starts a pool supervisor

sync(pool, function, timeout \\ 5000)

@spec sync(pool_supervisor(), execute_function(), non_neg_integer()) :: :ok

Enqueues a function call and awaits for it to be completed.