[macruby-changes] [3453] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Feb 8 15:05:16 PST 2010
Revision: 3453
http://trac.macosforge.org/projects/ruby/changeset/3453
Author: ernest.prabhakar at gmail.com
Date: 2010-02-08 15:05:16 -0800 (Mon, 08 Feb 2010)
Log Message:
-----------
Enumerable::p_mapdispatch works, but may not be thread safe
Modified Paths:
--------------
MacRuby/trunk/lib/dispatch/enumerable.rb
MacRuby/trunk/spec/macruby/library/dispatch/enumerable_spec.rb
Modified: MacRuby/trunk/lib/dispatch/enumerable.rb
===================================================================
--- MacRuby/trunk/lib/dispatch/enumerable.rb 2010-02-08 23:05:07 UTC (rev 3452)
+++ MacRuby/trunk/lib/dispatch/enumerable.rb 2010-02-08 23:05:16 UTC (rev 3453)
@@ -34,15 +34,16 @@
def p_mapreduce(result, op=:+, &block)
raise ArgumentError if not result.respond_to? op
# Since exceptions from a Dispatch block act funky
- q = Dispatch.queue_for(result)
+ @result = result
+ q = Dispatch.queue_for(@result)
self.p_each do |obj|
val = block.call(obj)
q.async do
- result = result.send(op, val)
+ @result = @result.send(op, val)
end
end
q.sync {}
- result
+ @result
end
Modified: MacRuby/trunk/spec/macruby/library/dispatch/enumerable_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/library/dispatch/enumerable_spec.rb 2010-02-08 23:05:07 UTC (rev 3452)
+++ MacRuby/trunk/spec/macruby/library/dispatch/enumerable_spec.rb 2010-02-08 23:05:16 UTC (rev 3453)
@@ -67,8 +67,8 @@
it "should behave like an unordered map" do
map1 = @ary.map {|v| v*v}
- map2 = @ary.p_mapreduce([]) {|v| v*v}
- map1.should == map2.sort
+ map2 = @ary.p_mapreduce([]) {|v| [v*v]}
+ map2.sort.should == map1
end
it "should accumulate any object that takes :<< " do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100208/4109d248/attachment.html>
More information about the macruby-changes
mailing list