Thread: Re: Win32 signal code - first try

Re: Win32 signal code - first try

From
"Merlin Moncure"
Date:
Magnus Hagander wrote:
> > Yes, this fine for polling, but what about when the backend
> > is *sleeping*?  As I understand the backend main processing
> It is if you use WaitForMultipleObjectsEx(). Or if you use
> WSAEventSelect() and then WaitForSingleObjectEx() on the event (this
> emulates select() the closest)

ok, as long as your are comfortable about that.

> Ok. Given this simplifications, we can use a single event, yes :-)
> So basically our polling would be:
>
> if (WaitForSingleObject(hSignalDeliveryEvent,0) == WAIT_OBJECT_0) {
>   DeliverSignals();
> }
>
> right?

Not quite.  Before We WFSO, we must first check if the signal is already
pending (as in my example earlier).  So we need one mask for pending
signals.

> If we are uncertain about delivering signals on an APC (with longjmp
> considerations etc), we could even just do our QueueUserAPC() ...

bleh.  If that is the case, we should be using events or your threadsafe
counter in your original example, not APC.  The whole point of the APC
is to keep the 'post poll' code simple and to keep us from having to
worry about what is going on in other threads than the main thread.

Merlin