[MacRuby-devel] [MacRuby] #447: GCD Crashes

Ernest N. Prabhakar, Ph.D. prabhaka at apple.com
Mon Nov 23 12:58:22 PST 2009


Hi John,

On Nov 23, 2009, at 12:55 PM, John Shea wrote:
> No I assume at some stage the ruby block has to be turned into a C block with associated scope - and from my limited knowledge on GCD that does not seem so easy. 

Again, I think I'm still missing your point. In the context of GCD, this is a non-issue since you don't *have* to use C blocks.  Instead, GCD provides a function pointer + context pointer API, which is what MacRuby uses:

http://github.com/masterkain/macruby/blob/master/gcd.c

>     if (RTEST(synchronous)){
>         dispatch_sync_f(RQueue(self)->queue, (void *)block,
> 		rb_queue_dispatcher);
>     } 
>     else {
>         dispatch_async_f(RQueue(self)->queue, (void *)block,
> 		rb_queue_dispatcher);
>     }

That is, C just treats the Ruby block as a data pointer.

-- Ernie P.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091123/1e1d5508/attachment-0001.html>


More information about the MacRuby-devel mailing list