Re: using grand central dispatch with c++ for inter-thread communication
Re: using grand central dispatch with c++ for inter-thread communication
- Subject: Re: using grand central dispatch with c++ for inter-thread communication
- From: Joel Reymont <email@hidden>
- Date: Wed, 21 Apr 2010 20:05:21 +0100
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden