Class: Async::Container::Hybrid
- Defined in:
- lib/async/container/hybrid.rb
Constant Summary
Constants inherited from Generic
Instance Attribute Summary
Attributes inherited from Generic
Instance Method Summary collapse
Methods inherited from Forked
Methods inherited from Generic
#[], #async, #failed?, #initialize, #key?, #mark?, #reload, run, #running?, #sleep, #spawn, #status?, #stop, #to_s, #wait, #wait_until_ready
Constructor Details
This class inherits a constructor from Async::Container::Generic
Instance Method Details
#run(count: nil, forks: nil, threads: nil, **options, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/async/container/hybrid.rb', line 29 def run(count: nil, forks: nil, threads: nil, **, &block) processor_count = Container.processor_count count ||= processor_count ** 2 forks ||= [processor_count, count].min threads = (count / forks).ceil forks.times do self.spawn(**) do container = Threaded::Container.new container.run(count: threads, **, &block) container.wait end end return self end |