Re: SIGIO and AppKit main loop
Re: SIGIO and AppKit main loop
- Subject: Re: SIGIO and AppKit main loop
- From: Bob Ippolito <email@hidden>
- Date: Mon, 29 Mar 2004 20:10:28 -0500
On Mar 29, 2004, at 1:08 PM, Douglas Davidson wrote:
On Mar 29, 2004, at 4:55 AM, Michael Rothwell wrote:
Cocoa appears to have no equivalent of glib's "IO Channels," which are
really useful, and do not use threads. GIOChannel integrates with the
application's main thread and invokes callback functions for
registered
events, such as ready-to-read, ready-to-write, ready-to-accept, etc. I
imagine it integrates the file descriptor in question with a
general-purpose select() or poll() done in the main application loop.
CFSocket does exactly that. The more convenient interfaces for most
purposes are the higher-level CFStream, NSStream, et al. See e.g.
<http://developer.apple.com/documentation/Networking/Conceptual/
CFNetwork/Preface/>
The original question referred to signals. Cocoa does not interfere
with signal delivery, but Cocoa calls must be treated as unsafe to use
from signal handlers. This is not a Cocoa-specific issue; there
really is very little that can be done safely from a signal handler.
The suggestion of setting a flag and handling it elsewhere is probably
best.
I've also seen signal handlers that send a message on a mach port
(that's also on the runloop) instead of setting a flag, which is better
because you don't end up polling. I believe I saw this first in the
mDNSResponder source code?
-bob
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.