Sha256: c0ac5dd7eeda9811587ce472aade52bcdff3b9cbb0cdb59f35d876940820a062
Contents?: true
Size: 693 Bytes
Versions: 1
Compression:
Stored size: 693 Bytes
Contents
require 'parallel_each.rb' require 'pp' describe "Parallelizing each/map" do it_should_behave_like "AppSwarm Test" it "should work at all" do Thread.list.select{|t|t.alive?}.length.should == 1 ma=[] mutex=Mutex.new a=(0..10).to_a a.p_each{|x|sleep rand(0.3); puts x; mutex.synchronize { ma<<x } } while ma.length<a.length sleep 0.1 end ma.sort.should == a Thread.list.select{|t|t.alive?}.length.should == 1 end it "should work for adding 1 in map" do a=(0..10).to_a a.p_map do |x| sleep rand(0.2) x+1 end.should == a.map{|x|x+1} Thread.list.select{|t|t.alive?}.length.should == 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | lib/appswarm/spec/parallel_each_spec.rb |