[macruby-changes] [4580] MacRuby/trunk/gcd.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Oct 5 14:31:56 PDT 2010
Revision: 4580
http://trac.macosforge.org/projects/ruby/changeset/4580
Author: lsansonetti at apple.com
Date: 2010-10-05 14:31:53 -0700 (Tue, 05 Oct 2010)
Log Message:
-----------
add Dispatch::Queue#dispatch_queue, which returns a pointer to the internal dispatch_queue_t object, useful when passing Ruby Queue objects to C/ObjC APIs accepting raw GCD types
Modified Paths:
--------------
MacRuby/trunk/gcd.c
Modified: MacRuby/trunk/gcd.c
===================================================================
--- MacRuby/trunk/gcd.c 2010-10-05 07:49:40 UTC (rev 4579)
+++ MacRuby/trunk/gcd.c 2010-10-05 21:31:53 UTC (rev 4580)
@@ -338,6 +338,12 @@
}
}
+static void *
+rb_queue_dispatch_queue_imp(void *rcv, SEL sel)
+{
+ return RQueue(rcv)->queue;
+}
+
static VALUE
rb_block_rescue(VALUE data, VALUE exc)
{
@@ -1245,7 +1251,12 @@
rb_queue_finalize_super = rb_objc_install_method2((Class)cQueue,
"finalize", (IMP)rb_queue_finalize);
-
+
+ // This API allows Ruby code to pass the internal dispatch_queue_t object
+ // to C/Objective-C APIs.
+ class_replaceMethod((Class)cQueue, sel_registerName("dispatch_queue"),
+ (IMP)rb_queue_dispatch_queue_imp, "^v@:");
+
qHighPriority = rb_queue_from_dispatch(dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_HIGH, 0), true);
qDefaultPriority = rb_queue_from_dispatch(dispatch_get_global_queue(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101005/64924ed1/attachment.html>
More information about the macruby-changes
mailing list