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

John Shea johnmacshea at gmail.com
Mon Nov 23 13:29:40 PST 2009


Hi again, 

thanks for the code ..

I am actually not trying to make a point - just trying to learn, and start a discussion that leads to learning.

since the code below means nothing to me - thats probably a good place for me to start.

Cheers,
J

On Nov 23, 2009, at 9:58 PM, Ernest N. Prabhakar, Ph.D. wrote:

> 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.
> 
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

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


More information about the MacRuby-devel mailing list