[macruby-changes] [3366] MacRuby/trunk/lib

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 29 15:40:09 PST 2010


Revision: 3366
          http://trac.macosforge.org/projects/ruby/changeset/3366
Author:   ernest.prabhakar at gmail.com
Date:     2010-01-29 15:40:08 -0800 (Fri, 29 Jan 2010)
Log Message:
-----------
Rename futures to future to match class name

Modified Paths:
--------------
    MacRuby/trunk/lib/dispatch.rb

Added Paths:
-----------
    MacRuby/trunk/lib/dispatch/future.rb

Removed Paths:
-------------
    MacRuby/trunk/lib/dispatch/futures.rb

Copied: MacRuby/trunk/lib/dispatch/future.rb (from rev 3365, MacRuby/trunk/lib/dispatch/futures.rb)
===================================================================
--- MacRuby/trunk/lib/dispatch/future.rb	                        (rev 0)
+++ MacRuby/trunk/lib/dispatch/future.rb	2010-01-29 23:40:08 UTC (rev 3366)
@@ -0,0 +1,24 @@
+# Calculate the value of an object in the background
+
+module Dispatch
+  # Wrapper around Dispatch::Group used to implement lazy Futures 
+  class Future
+    # Create a future that asynchronously dispatches the block 
+    # to a concurrent queue of the specified (optional) +priority+
+    def initialize(priority=nil, &block)
+      @value = nil
+      @group = Dispatch.fork(priority) { @value = block.call }
+    end
+
+    # Waits for the computation to finish, then returns the value
+    # Duck-typed to lambda.call(void)
+    # If a block is passed, invoke that asynchronously with the final value
+    def call(&callback)
+      if not block_given?
+        @group.wait
+        return @value
+      end
+      @group.notify { callback.call(@value) }
+    end
+  end
+end

Deleted: MacRuby/trunk/lib/dispatch/futures.rb
===================================================================
--- MacRuby/trunk/lib/dispatch/futures.rb	2010-01-29 23:40:06 UTC (rev 3365)
+++ MacRuby/trunk/lib/dispatch/futures.rb	2010-01-29 23:40:08 UTC (rev 3366)
@@ -1,22 +0,0 @@
-module Dispatch
-  # Wrapper around Dispatch::Group used to implement lazy Futures 
-  class Future
-    # Create a future that asynchronously dispatches the block 
-    # to a concurrent queue of the specified (optional) +priority+
-    def initialize(priority=nil, &block)
-      @value = nil
-      @group = Dispatch.fork(priority) { @value = block.call }
-    end
-
-    # Waits for the computation to finish, then returns the value
-    # Duck-typed to lambda.call(void)
-    # If a block is passed, invoke that asynchronously with the final value
-    def call(&callback)
-      if not block_given?
-        @group.wait
-        return @value
-      end
-      @group.notify { callback.call(@value) }
-    end
-  end
-end

Modified: MacRuby/trunk/lib/dispatch.rb
===================================================================
--- MacRuby/trunk/lib/dispatch.rb	2010-01-29 23:40:06 UTC (rev 3365)
+++ MacRuby/trunk/lib/dispatch.rb	2010-01-29 23:40:08 UTC (rev 3366)
@@ -3,7 +3,7 @@
 # 
 # Copyright (C) 2010  Apple, Inc.
 # 
-# == Overview
+# == Overview ==
 #
 # Grand Central Dispatch (GCD) is a novel approach to multicore computing
 # first released in Mac OS X version 10.6 Snow Leopard.
@@ -12,11 +12,11 @@
 # This library provides higher-level services and convenience methods
 # to make it easier for traditional Ruby programmers to add multicore support.
 
-raise "Dispatch will only work on Mac OS X 10.6 or later" if MACOSX_VERSION < 10.6
+raise "Dispatch only works on Mac OS X 10.6 or later" if MACOSX_VERSION < 10.6
 
 require 'dispatch/actor'
 require 'dispatch/dispatch'
+require 'dispatch/enumerable'
+require 'dispatch/futures'
 require 'dispatch/queue'
 require 'dispatch/queue_source'
-require 'dispatch/enumerable'
-require 'dispatch/futures'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100129/4f3b4bc5/attachment-0001.html>


More information about the macruby-changes mailing list