Re: Run loops: Mach messages vs. kqueues
Re: Run loops: Mach messages vs. kqueues
- Subject: Re: Run loops: Mach messages vs. kqueues
- From: David Leimbach <email@hidden>
- Date: Wed, 20 Jan 2010 09:11:32 -0800
On Wed, Jan 20, 2010 at 9:07 AM, Damien Sorresso
<email@hidden> wrote:
On Jan 20, 2010, at 1:38 AM, Dave Keck wrote:
> Hello,
>
> Is there a reason that CFRunLoop is implemented atop Mach messages
> rather than a kqueue? If it were implemented atop a kqueue, not only
> would CFRunLoop maintain support for waking when a Mach message
> arrives, but it could also be awoken when data is available on an
> arbitrary file descriptor. (As far as I'm aware, the only way to do
> this currently is to spawn a secondary thread to monitor the
> descriptor and message the original thread to wake it.)
>
> It seems a kqueue-CFRunLoop would improve efficiency quite a bit at no
> cost; I've written a lot of code that uses the secondary thread
> technique, and I know there's a lot of system APIs that do the same
> (CFFileDescriptor and CFSocket to name a few.)
>
> I did notice that kqueues just gained support for monitoring Mach
> messages in 10.6 though, so perhaps CFRunLoop has just been waiting
> for support in the kernel?
David,
CFRunLoop has been around for a very long time, since the 10.0 days, well before kqueue was implemented on Mac OS X. I would not be surprised if moving it to a kqueue-based firing mechanism would introduce binary incompatibilities. (Also, I believe that CFMachPort has been around just as long as CFRunLoop; it wasn't just added in Snow Leopard.)
In any case, you really want a GCD run loop.
It actually looks, from the code, that libdispatch is already creeping into CFRunLoop. Since libdispatch/GCD uses kqueues, I think it will all converge in time, but only Apple can answer that question :-)
Dave
--
Damien Sorresso
BSD Engineering
Apple Inc.
_______________________________________________
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
_______________________________________________
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