I write the following script in order to understand Celluloid.
require 'celluloid/current'
class Processor
include Celluloid
def perfom(number)
puts "#{number} ... (#{Thread.current}) ..."
sleep(number%3)
puts "Launch finish!"
return number
end
end
pool = Processor.pool(size: 3)
futures = (1..7).map do |i|
pool.future(:perfom, i)
end
puts futures.map(&:value)
pool.terminate
All work fine and i want to avoid to call the terminate on the pool.
So i try to use supervisor but it raise me uninitialized constant Celluloid::SupervisionGroup
After search I find this (in deprecated folder) : (https://github.com/celluloid/celluloid-supervision/blob/master/spec/celluloid/deprecate/supervision/supervision_group_spec.rb)
I wanted to make work something like :
supervisor = Celluloid::SupervisionGroup.run!
pool = supervisor.pool(Processor, size: 3, as: :worker)
futures = (1..7).map do |i|
pool[:worker].future(:perfom, i)
end
puts futures.map(&:value)
How can I make work future, supervisor and pool with the new system?