class ActiveConcurrency::Base::Pool
Public Class Methods
new(size: 2, scheduler: DEFAULT_SCHEDULER, **options)
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 9 def initialize(size: 2, scheduler: DEFAULT_SCHEDULER, **options) size = [size, options[:topics].size].max if options.key?(:topics) @pool = Array.new(size) { |n| worker.new(name: n) } @scheduler = scheduler.new(@pool, options) end
Public Instance Methods
clear()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 15 def clear @pool.map(&:clear) end
close()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 19 def close @pool.map(&:close) end
closed()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 23 def closed @pool.each_with_object({}) do |w, h| h[w.name] = w.closed? end end
exit()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 29 def exit @pool.map(&:exit) end
exit!()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 33 def exit! @pool.map(&:exit!) end
join()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 41 def join @pool.map(&:join) end
lock()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 45 def lock @pool.map(&:lock) end
schedule(*args, &block)
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 37 def schedule(*args, &block) @scheduler.schedule(*args, &block) end
shutdown()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 55 def shutdown @pool.map(&:shutdown) end
sizes()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 49 def sizes @pool.each_with_object({}) do |w, h| h[w.name] = w.size end end
statuses()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 59 def statuses @pool.each_with_object({}) do |w, h| h[w.name] = w.status end end
Private Instance Methods
worker()
click to toggle source
# File lib/active_concurrency/base/pool.rb, line 67 def worker modules = self.class.name.split('::')[0..1] klass = modules.push('Worker').join('::') ::Object.const_get(klass) end