Sha256: db76e6fc7aeb8a47dbf0c3a23a42eeed4ff8a407db34a843ce457f193c138d0f
Contents?: true
Size: 701 Bytes
Versions: 1
Compression:
Stored size: 701 Bytes
Contents
# # forkoff does *NOT* spawn processes in batches, waiting for each batch to # complete. rather, it keeps a certain number of processes busy until all # results have been gathered. in otherwords the following will ensure that 2 # processes are running at all times, until the list is complete. note that # the following will take about 2 seconds to run (2 sets of 2 @ 1 second). # require 'forkoff' pid = Process.pid a = Time.now.to_f pstrees = %w( a b c d ).forkoff! :processes => 2 do |letter| sleep 1 { letter => ` pstree -l 2 #{ pid } ` } end b = Time.now.to_f puts puts "pid: #{ pid }" puts "elapsed: #{ b - a }" puts require 'yaml' pstrees.each do |pstree| y pstree end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
forkoff-0.0.0 | samples/c.rb |