class Concurrent::Actor::Utils::Pool

Allows to create a pool of workers and distribute work between them @param [Integer] size number of workers @yield [balancer, index] a block spawning an worker instance. called size times.

The worker should be descendant of AbstractWorker and supervised, see example.

@yieldparam [Balancer] balancer to pass to the worker @yieldparam [Integer] index of the worker, usually used in its name @yieldreturn [Reference] the reference of newly created worker @example

class Worker < Concurrent::Actor::RestartingContext
  def on_message(message)
    p message * 5
  end
end

pool = Concurrent::Actor::Utils::Pool.spawn! 'pool', 5 do |index|
  Worker.spawn name: "worker-#{index}", supervise: true, args: []
end

pool << 'asd' << 2
# prints:
# "asdasdasdasdasd"
# 10