Modified: MacRuby/trunk/lib/dispatch/future.rb (3464 => 3465)
--- 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 (3464 => 3465)
--- 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