Re: using grand central dispatch with c++ for inter-thread communication
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to:x-mailer; bh=2XHdKGAI7S9cc8LfHu+8Y7jk+5RuFBufiu2gFUqBCSE=; b=NVgFlW+OPoljDd28sqd3vnI0rCYE+kUk5ww/alB/FoVbpCAyEF9ojiPd5HJiYon7Ev PUmcesa1suaMXxebow7sTXkr3rMNwzqodONI48hFql+3k+QvdnJkTNkGKMq2/b1prwF7 nZE4IiMDxRRg3iPV+L+7qnD1zKhqhQmHsP2Ow= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=QuzXcLdMj1acQT+qI9LAKl7kh6DR6s+WPWbt6/rJqFEitujlVNzaiTGBIMPovgsecW GQvWDja2Pd3z5mLwAep0SuMWon9/EyOVrlrfG6i0WsWiIQP9IQEL/eT5WtPs3yiWsSI4 RMF4O6+fDZbkKFJJfptFkdr6fYKWUlRPbkBeE= On Apr 21, 2010, at 7:37 PM, Kevin Van Vechten wrote:
The API for CFRunLoop requires that you manage the threads yourself. The goal of GCD is for you to work with queues that may or may not be backed by threads at any given time.
I looked at using dispatch queues at first but got stuck. This may be just the opportunity to get me over the stumbling block! This is the crucial bit of code that I can't figure out how to translate to dispatch queues: static IONotificationPortRef __NotifyPort; // add notification port and run loop source for async notifications __NotifyPort = IONotificationPortCreate(masterPort); runLoopSource = IONotificationPortGetRunLoopSource(__NotifyPort); // set up run loop for our driver thread __MeasatRunLoop = CFRunLoopGetCurrent(), CFRunLoopAddSource(__MeasatRunLoop, runLoopSource, kCFRunLoopDefaultMode); and then // set up notification to detect plugging of Measat without firmware kr = IOServiceAddMatchingNotification( __NotifyPort, kIOFirstMatchNotification, matchingDict, RawDeviceAdded, NULL, &__RawAddedIter ); I see dispatch_source_create as a candidate to replace CFRunLoopAddSource but what dispatch source type should I use? There's one for Mach receive and one for Mach send. Which one should I use with the Mach port behind the IO Notification Port? I'm assuming here that I need to get hold of the underlying Mach port. Thanks, Joel --- http://es.linkedin.com/in/joelreymont http://twitter.com/wagerlabs _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Joel Reymont