[macruby-changes] [3465] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 9 15:24:14 PST 2010


Revision: 3465
          http://trac.macosforge.org/projects/ruby/changeset/3465
Author:   ernest.prabhakar at gmail.com
Date:     2010-02-09 15:24:14 -0800 (Tue, 09 Feb 2010)
Log Message:
-----------
Added high-level Dispatch.future method around Dispatch::Future.new

Modified Paths:
--------------
    MacRuby/trunk/lib/dispatch/future.rb
    MacRuby/trunk/spec/macruby/library/dispatch/future_spec.rb

Modified: MacRuby/trunk/lib/dispatch/future.rb
===================================================================
--- MacRuby/trunk/lib/dispatch/future.rb	2010-02-09 23:23:38 UTC (rev 3464)
+++ MacRuby/trunk/lib/dispatch/future.rb	2010-02-09 23:24:14 UTC (rev 3465)
@@ -21,7 +21,14 @@
         q ||= Dispatch::Queue.concurrent
         @group.notify(q) { callback.call(@value) }
       end
-    end
-        
+    end   
   end
+  
+  # Create a +Future+ that runs the block in the background
+  def future(priority=nil, &block)
+    Future.new(priority, &block)
+  end
+  
+  module_function :future
+  
 end

Modified: MacRuby/trunk/spec/macruby/library/dispatch/future_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/library/dispatch/future_spec.rb	2010-02-09 23:23:38 UTC (rev 3464)
+++ MacRuby/trunk/spec/macruby/library/dispatch/future_spec.rb	2010-02-09 23:24:14 UTC (rev 3465)
@@ -11,6 +11,8 @@
     describe :new do
       it "should return an Future for tracking execution of the passed block" do
         @future.should be_kind_of Dispatch::Future
+        future = Dispatch.future { Math.sqrt(2**10) }
+        future.should be_kind_of Dispatch::Future
       end
     end
     
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100209/05d9f134/attachment.html>


More information about the macruby-changes mailing list