diff --git a/lib/parallel.rb b/lib/parallel.rb index 612602b4..9b6077bd 100644 --- a/lib/parallel.rb +++ b/lib/parallel.rb @@ -232,6 +232,7 @@ def each_with_index(array, options={}, &block) end def map(source, options = {}, &block) + options = options.dup options[:mutex] = Mutex.new if options[:in_processes] && options[:in_threads] diff --git a/spec/parallel_spec.rb b/spec/parallel_spec.rb index cd6e2b1f..c722278a 100644 --- a/spec/parallel_spec.rb +++ b/spec/parallel_spec.rb @@ -225,6 +225,10 @@ def cpus }.should <= 3.5 end + it "does not modify options" do + lambda { Parallel.map([], {}.freeze) }.should_not raise_error + end + it "executes with given parameters" do `ruby spec/cases/parallel_map.rb`.should == "-a- -b- -c- -d-" end @@ -233,7 +237,7 @@ def cpus `ruby spec/cases/parallel_map_complex_objects.rb`.should == "YES" end - it "starts new process imediatly when old exists" do + it "starts new process immediately when old exists" do time_taken{ `ruby spec/cases/parallel_map_uneven.rb` }.should <= 3.5