From: Fredrik Date: 2008-04-18T15:45:05+09:00 Subject: Re: Parallel for loop > It's different with blocks: (reposting, my last post didn't appear(?)) Great, thanks for that lesson! It would look like this then. def forkmap(n = nil) nproc = 0 result = map do |*a| r, w = IO.pipe fork do r.close w.write( Marshal.dump( yield(*a) ) ) end if n and (nproc+=1) >= n Process.wait ; nproc -= 1 end [ w.close, r ].last end Process.waitall result.map{|r| Marshal.load [ r.read, r.close ].first} end