I don't know about any established patterns (anybody?), but you'll probably have to do some work on the source side to associate those "events" with a consumer, e.g., by posting something to a queue with a condition variable, like pushing instead of pulling. If the source isn't active, you'll have to run a thread to wait for events and translate them into events pushed onto the queue (notifying any consumers about their presence), which seems a bit annoying. Of course, when you're doing that, you might as well enqueue tasks instead, I suppose.
void WaitAll ( const size_t timeInMS ); //timeInMS to wait/timeout or 0 for infinite int WaitAny ( const size_t timeInMS ); //return the event # in the list triggered, or -1 for timeout, <-1 on error int WaitSingle ( const size_t eventID ); //eventID=event # in the list. Return 0 on trigger, -1 on timeour, <-1 if error
With a condition variable a thread waits for a signal sent through the variable. Signals can be sent at any given time under whatever logical condition(s) a program wants to use. The persistence of conditions should also be guaranteed by the program; condition variable is just a general waiting mechanism.
The basic schema to emulate WaitForMultipleObjects is the following: - a waiting thread, when woken up, checks for all logical conditions it is interested in, and if any is not satisfied, itwaits again, otherwise proceeds; - whenever any of the tracked conditions changes to true, the thread that made the change should notify all threads waiting on the condition variable.