#477: Need GCD wrapper for dispatch_once ----------------------------------------+----------------------------------- Reporter: ernest.prabha...@… | Owner: lsansone...@… Type: enhancement | Status: new Priority: minor | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: ----------------------------------------+-----------------------------------
Comment(by lsansone...@…): The only way I see to implement this (without hacking the compiler) is to keep a static map of dispatch_once_t structures dynamically allocated on the fly and using the position of the caller within the stack frame as the unique id (key). However, accessing the table in a thread-safe manner will imply to keep it protected with a lock. I therefore wonder if all of this is really worth doing, since a call to Dispatch.once will be costlier than expected, and very similar to the following pure-Ruby code (which should even run faster): {{{ @lock = Mutex.new .. @lock.synchronize do @called ||= false unless @called do_stuff @called = true end end }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/477#comment:6> MacRuby <http://macruby.org/> _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel