
Don G skryf:
That makes sense, and I have used that feature before. The hard part about putting this technique to use in a library is that it makes requirements on the behavior of main: it must be in an alertable wait. If I recall correctly, GetMessage/PeekMessage are not alertable.
I like the way the ACE library handles this. You have a choice of two architectural patterns: Reactor and proactor. Reactor makes your service "reactive" by serially demultiplexing events synchronously (Proactor has mutliple threads ready to do work). To start handling events you call "handle_events". You don't really care if the call puts your thread in an alertable wait or not. That would depend on whether the reactor uses the Select_Reactor or WFMO_Reactor implementation. These patterns nicely decouple event demuxing and dispatching from all the other processing. Hugo Duncan's Giallo project uses them also. Groete Hans