site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com On Aug 20, 2010, at 7:35 AM, Jerry Krinock wrote:
On 2010 Aug 20, at 01:28, Terry Lambert wrote:
Why not have a timeout on the kevent…
This is _a_ way, but your timeout would need to be tight to ensure that it was more or less responsive…
Actually I could do that, since this is just to clean up resources; no hurry. But then there's that "elegance" thing. "Polling", anyone? Seems like it defeats the purpose of kqueue.
Alternately, the NSThread in 10.5.x is based on a pthread, so you could do: volatile pthread_t kqueue_thread; // called within the thread before looping kqueue_thread = pthread_self();
I use pipes added as kqueue events for inter-thread communications. This also allows for an arbitrarily-sized payload to go along with the events itself (in the form of a pipe message). However, you know that sending a signal to a thread does not have to imply asynchronous behavior, right? You can add the signal to be handled by kqueue as a simple event. In your design, instead of managing the kqueue fd in the main thread, I would hand it to the new thread, and send a cleanup signal via the pipe (or UNIX signal) to the secondary thread to end it. Cheers, M _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com