Revision: 4323 http://trac.macosforge.org/projects/ruby/changeset/4323 Author: ernest.prabhakar@gmail.com Date: 2010-07-07 10:56:01 -0700 (Wed, 07 Jul 2010) Log Message: ----------- Synthesize header for dispatch_methods.rb Modified Paths: -------------- MacRuby/trunk/lib/dispatch/README.rdoc MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh Property Changed: ---------------- MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh Modified: MacRuby/trunk/lib/dispatch/README.rdoc =================================================================== --- MacRuby/trunk/lib/dispatch/README.rdoc 2010-07-07 17:55:59 UTC (rev 4322) +++ MacRuby/trunk/lib/dispatch/README.rdoc 2010-07-07 17:56:01 UTC (rev 4323) @@ -29,7 +29,6 @@ Note that MacRuby 0.6 is currently (as of March 2010) only available as source[http://www.macruby.org/source.html] or via the {nightly builds}[http://www.icoretech.org/2009/09/macruby-nightlies/]. The examples all assume you run the latest macirb and require the +dispatch+ library: $ macirb - #!/usr/local/bin/macruby require 'dispatch' We also assume that you are already familiar with Ruby, though not necessarily MacRuby. No prior knowledge of C or GCD is assumed or required, but the {dispatch(3) man page}[http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPag...] may be helpful if you wish to better understand the underlying semantics. @@ -108,7 +107,7 @@ then ask it to wrap the object you want to modify from multiple threads: @hash = job.synchronize Hash.new - puts "#{@hash.class} => Dispatch::Proxy" # + puts "#{@hash.class} => Dispatch::Proxy" This is actually the same type of object used to manage the list of +values+: Modified: MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb =================================================================== --- MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb 2010-07-07 17:55:59 UTC (rev 4322) +++ MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb 2010-07-07 17:56:01 UTC (rev 4323) @@ -1,4 +1,5 @@ #!/usr/local/bin/macruby + require 'dispatch' job = Dispatch::Job.new { Math.sqrt(10**100) } @result = job.value @@ -11,13 +12,13 @@ job.join { puts "join done (async)" } job.add { Math.sqrt(2**64) } job.value {|b| puts "#{b} => 4294967296.0" } -@values = job.values +@values = job.values puts "#{@values.inspect} => [1.0E50]" job.join puts "#{@values.inspect} => [1.0E50, 4294967296.0]" job = Dispatch::Job.new {} @hash = job.synchronize Hash.new -puts "#{@hash.class} => Dispatch::Proxy" # +puts "#{@hash.class} => Dispatch::Proxy" puts "#{job.values.class} => Dispatch::Proxy" @@ -34,7 +35,7 @@ @hash.inspect { |s| puts "#{s} => {64 => 1.0E32, 100 => 1.0E50}" } delegate = @hash.__value__ -puts "\n#{delegate.class} => Hash" +puts "\n#{delegate.class} => Hash" n = 42 job = Dispatch::Job.new { puts "#{n} => 42" } @@ -78,7 +79,7 @@ puts "done p_map(3) [sometimes fails!?!]" mr = (0..4).p_mapreduce(0) { |i| 10**i } puts "#{mr} => 11111" -mr = (0..4).p_mapreduce([], :concat) { |i| [10**i] } +mr = (0..4).p_mapreduce([], :concat) { |i| [10**i] } puts "#{mr} => [1, 1000, 10, 100, 10000]" mr = (0..4).p_mapreduce([], :concat, 3) { |i| [10**i] } @@ -120,7 +121,7 @@ masker.resume! masker.cancel! @event = 0 -mask = Dispatch::Source::PROC_EXIT | Dispatch::Source::PROC_SIGNAL +mask = Dispatch::Source::PROC_EXIT | Dispatch::Source::PROC_SIGNAL proc_src = Dispatch::Source.process($$, mask) do |s| @event |= s.data end Modified: MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh =================================================================== --- MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh 2010-07-07 17:55:59 UTC (rev 4322) +++ MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh 2010-07-07 17:56:01 UTC (rev 4323) @@ -1,3 +1,5 @@ #!/bin/sh DISPATCH=../../../lib/dispatch -grep " " $DISPATCH/README.rdoc | sed "s/ //" | grep -v '\$ ' | tail +2 +/bin/echo -n "#!" +which macruby +grep " " $DISPATCH/README.rdoc | sed "s/ //" | grep -v '\$ ' Property changes on: MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.sh ___________________________________________________________________ Added: svn:executable + *
participants (1)
-
source_changes@macosforge.org