Class: Async::Container::Hybrid
- Inherits:
-
Forked
- Object
- Controller
- Forked
- Async::Container::Hybrid
- Defined in:
- lib/async/container/hybrid.rb
Constant Summary
Constants inherited from Forked
Instance Attribute Summary
Attributes inherited from Forked
Instance Method Summary collapse
Methods inherited from Forked
#initialize, multiprocess?, run, #spawn, #stop, #wait
Methods inherited from Controller
#async, #attach, #initialize, #stop
Constructor Details
This class inherits a constructor from Async::Container::Forked
Instance Method Details
#run(count: nil, forks: nil, threads: nil, **options, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/async/container/hybrid.rb', line 28 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.new container.run(count: threads, **, &block) container.wait end end return self end |