Re: How to kill a kqueue camper thread? Was: close() hangs … in 10.5 only
Re: How to kill a kqueue camper thread? Was: close() hangs … in 10.5 only
- Subject: Re: How to kill a kqueue camper thread? Was: close() hangs … in 10.5 only
- From: "A.M." <email@hidden>
- Date: Fri, 20 Aug 2010 10:37:57 -0400
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden