[MacRuby] #420: GCD serial dispatch queues and groups that contain serial queues do not take surrounding scope reliably within loops/enumerators
#420: GCD serial dispatch queues and groups that contain serial queues do not take surrounding scope reliably within loops/enumerators -----------------------------------+---------------------------------------- Reporter: johnmacshea@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: GCD -----------------------------------+---------------------------------------- See attached file with examples. Summary:[[BR]] - variables changed during a loop will not get passed correctly to the serial or group (with serial) queues, and quite often cause crashes.[[BR]] - if the loop has block variable (eg 100.times do |index|) the variable will be passed correctly most of the time, but no other changing variables will be.[[BR]] [[BR]] - when the loops are unrolled the dispatch queues take up the variables correctly - perhaps suggesting that it is yield issue within the enumerators. -- Ticket URL: <http://www.macruby.org/trac/ticket/420> MacRuby <http://macruby.org/>
#420: GCD serial dispatch queues and groups that contain serial queues do not take surrounding scope reliably within loops/enumerators -----------------------------------+---------------------------------------- Reporter: johnmacshea@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: GCD | -----------------------------------+---------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.5 Comment: I looked at your test script, extracted the first snippet and tested it with ToT (r3056). It seems to work as expected. I had to modify your snippet to use a group in order to wait for pending blocks (otherwise the program exists prematurely). {{{ $ cat t.rb lock = Dispatch::Queue.new("org.johnmacshea.lock") group = Dispatch::Group.new results = [] 100.times do |index| serial = Dispatch::Queue.new("org.johnmacshea.serial_#{index}") group.dispatch(serial) do sleep rand(5) p index lock.dispatch {results << "#{index}"} end end group.wait }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/420#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby