[MacRuby-devel] [MacRuby] #476: GCD Groups should be a wrapper around dispatch, not its own invocation style

MacRuby ruby-noreply at macosforge.org
Mon Dec 7 17:06:45 PST 2009


#476: GCD Groups should be a wrapper around dispatch, not its own invocation
style
----------------------------------------+-----------------------------------
 Reporter:  ernest.prabhakar@…          |       Owner:  lsansonetti@…        
     Type:  enhancement                 |      Status:  new                  
 Priority:  blocker                     |   Milestone:  MacRuby 0.5          
Component:  MacRuby                     |    Keywords:  gcd                  
----------------------------------------+-----------------------------------

Comment(by conradwt@…):

 Here's a better representation and it's associated usage:

 API:
 {{{

 module Dispatch

   # constants...
   TIME_FOREVER = 1

   class Queue

      def initialize( label, attribute = nil )
        @label = label
        @attribute = attribute
      end

      def dispatch_async( &block )
      end

      def dispatch_sync( &block )
      end

      def dispatch_apply( iterations, &block )
      end

   end

   class Group

     def dispatch_async( queue, &block )
     end

     def dispatch_wait( timeout )
     end

     def dispatch_release
     end

   end

 end

 }}}

 USAGE:
 {{{
 block = lambda { do_some_work }

 queue = Dispatch::Queue.new( "comp.lang.MyCustomerQueue" )
 queue.dispatch_async( &block )
 queue.dispatch_sync( &block )
 queue.dispatch_apply( 5, &block )

 group = Dispatch::Group.new
 group.dispatch_async( queue, &block )
 group.dispatch_wait( Dispatch::TIME_FOREVER )
 group.dispatch_release

 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/476#comment:9>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list