[macruby-changes] [4325] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Jul 7 16:06:48 PDT 2010


Revision: 4325
          http://trac.macosforge.org/projects/ruby/changeset/4325
Author:   ernest.prabhakar at gmail.com
Date:     2010-07-07 16:06:47 -0700 (Wed, 07 Jul 2010)
Log Message:
-----------
Added Dispatch::Queue#join to sync {}

Modified Paths:
--------------
    MacRuby/trunk/lib/dispatch/queue.rb
    MacRuby/trunk/spec/macruby/library/dispatch/queue_spec.rb

Modified: MacRuby/trunk/lib/dispatch/queue.rb
===================================================================
--- MacRuby/trunk/lib/dispatch/queue.rb	2010-07-07 20:04:02 UTC (rev 4324)
+++ MacRuby/trunk/lib/dispatch/queue.rb	2010-07-07 23:06:47 UTC (rev 4325)
@@ -26,5 +26,8 @@
       new(labelize(obj))
     end
     
+    def join
+      sync {}
+    end
   end
 end

Modified: MacRuby/trunk/spec/macruby/library/dispatch/queue_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/library/dispatch/queue_spec.rb	2010-07-07 20:04:02 UTC (rev 4324)
+++ MacRuby/trunk/spec/macruby/library/dispatch/queue_spec.rb	2010-07-07 23:06:47 UTC (rev 4325)
@@ -6,6 +6,7 @@
   describe "Dispatch::Queue" do
     before :each do
       @my_object = "Hello, World!"
+      @q = Dispatch::Queue.for(@my_object)
     end
 
     describe :labelize do
@@ -18,21 +19,28 @@
 
     describe :for do
       it "should return a dispatch queue" do
-        q = Dispatch::Queue.for(@my_object)
-        q.should be_kind_of Dispatch::Queue
+        @q.should be_kind_of Dispatch::Queue
       end
 
       it "should return a unique queue for each object" do
-        q1 = Dispatch::Queue.for(@my_object)
-        q2 = Dispatch::Queue.for(@my_object)
-        q1.should_not == q2
+        q = Dispatch::Queue.for(@my_object)
+        @q.should_not == q
       end
 
       it "should return a unique label for each queue" do
-        q1 = Dispatch::Queue.for(@my_object)
-        q2 = Dispatch::Queue.for(@my_object)
-        q1.to_s.should_not == q2.to_s
+        q = Dispatch::Queue.for(@my_object)
+        @q.to_s.should_not == q.to_s
       end
     end
+
+    describe :join do
+      it "should wait until pending blocks execute " do
+        @n = 0
+        @q.async {@n = 42}
+        @n.should == 0
+        @q.join
+        @n.should == 42        
+      end
+    end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100707/4dde3468/attachment-0001.html>


More information about the macruby-changes mailing list