Sha256: 2764862694772f441fec9bc03a4dfcd1950a7e51c3cbcc50eab231af71cb8fe7
Contents?: true
Size: 391 Bytes
Versions: 1
Compression:
Stored size: 391 Bytes
Contents
# frozen_string_literal: true require "etc" class Quickdraw::Cluster def self.call(n = Etc.nprocessors, &) spawn(n, &).wait end def self.spawn(n = Etc.nprocessors, &block) new.tap do |cluster| n.times { cluster.fork(&block) } end end def initialize @workers = [] end def fork(&) @workers << Quickdraw::Worker.fork(&) end def wait @workers.map(&:wait) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickdraw-0.1.0 | lib/quickdraw/cluster.rb |