Class: Async::Container::Hybrid

Inherits:
Forked show all
Defined in:
lib/async/container/hybrid.rb

Constant Summary

Constants inherited from Forked

Forked::UNNAMED

Instance Attribute Summary

Attributes inherited from Forked

#statistics

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, **options, &block)
	processor_count = Container.processor_count
	count ||= processor_count ** 2
	forks ||= [processor_count, count].min
	threads = (count / forks).ceil
	
	forks.times do
		self.spawn(**options) do
			container = Threaded.new
			
			container.run(count: threads, **options, &block)
			
			container.wait
		end
	end
	
	return self
end