class

Earl::Pool(A, M)

Inherits Earl::Mailbox < Earl::Logger < Earl::Agent < Earl::Artist < Reference < Object

Maintains a pool of worker agents of type A that will be spawned and monitored.

The pool will always be filled to its maximum capacity.

Workers

Crashed and unexpectedly stopped workers will be recycled and restarted, until the pool is asked to stop.

Worker agents can return as soon as possible when asked to stop, or keep processing their mailbox until its empty.

Mailbox

Workers must include the Mailbox(M) module. Messages will be dispatched to a single worker in an at-most-once manner.

Constructors

new(capacity : Int32)

Instance methods

call(message : M)
call

Spawns workers in their dedicated Fiber. Blocks until all workers have stopped.

terminate

Asks each worker to stop.

trap(agent : A, exception : Exception | Nil) : Nil

Recycles and restarts crashed and unexpectedly stopped agents.