Class: Quickdraw::Cluster
- Inherits:
-
Object
- Object
- Quickdraw::Cluster
- Defined in:
- lib/quickdraw/cluster.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fork ⇒ Object
-
#initialize ⇒ Cluster
constructor
A new instance of Cluster.
- #wait ⇒ Object
Constructor Details
#initialize ⇒ Cluster
Returns a new instance of Cluster.
16 17 18 |
# File 'lib/quickdraw/cluster.rb', line 16 def initialize @workers = [] end |
Class Method Details
.call(n = Etc.nprocessors) ⇒ Object
6 7 8 |
# File 'lib/quickdraw/cluster.rb', line 6 def self.call(n = Etc.nprocessors, &) spawn(n, &).wait end |
.spawn(n = Etc.nprocessors, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/quickdraw/cluster.rb', line 10 def self.spawn(n = Etc.nprocessors, &block) new.tap do |cluster| n.times { cluster.fork(&block) } end end |