[MacRuby-devel] [MacRuby] #420: GCD serial dispatch queues and groups that contain serial queues do not take surrounding scope reliably within loops/enumerators

MacRuby ruby-noreply at macosforge.org
Fri Nov 27 17:08:03 PST 2009


#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/>



More information about the MacRuby-devel mailing list