[MacRuby-devel] [MacRuby] #597: Dispatch Queue async method inconsistent results
MacRuby
ruby-noreply at macosforge.org
Wed Feb 3 01:33:53 PST 2010
#597: Dispatch Queue async method inconsistent results
--------------------------------------+-------------------------------------
Reporter: Knut.Olaf.Lien@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords: GCD async method
--------------------------------------+-------------------------------------
Trying to run this:
## Fibionti example showing Grand Central Dispatch in action
## using MacRuby
## Feb. 2, 2010
def fib(n=1)
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end
q = Dispatch::Queue.concurrent
grp = Dispatch::Group.new
result = []
8.times do |index|
q.async(grp) do
result[index] = fib(ARGV[0].to_i)
end
end
## Wait for the result to be calculated and print the results
grp.wait
puts result
Gives inconsistent fibionati results, i.e. some of the values become false
instead of the correct fibionati number. No clue if this is a bug or just
my implementation is wrong.
--
Ticket URL: <http://www.macruby.org/trac/ticket/597>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list