I decided to reward myself for a successful (and on-time!) product ship (the first units
were shipped this morning) by taking time to write an essay. What I had to do was come up
with a simple, interthread communication mechanism that did NOT use PostMessage, because
the high volume of messages killed the GUI by having its queue always full of data
messages. Furthermore, I had to handle the case were the existing code base (some 40K
lines of code) did not have to change substantially to accommodate this. More seriously
than the enqueuing of messages was the handling of them; I'd already built a complex
collection of ON_REGISTERED_MESSAGE handlers.
What I did was use an I/O Completion Port for interthread messaging. I use the OnIdle
handler to dequeue the messages from the port and enqueue them (in small quantities) to
the GUI thread. The result was that except for a few substitutations for the PostMessage
call, nothing else changed.
The essay can be found at
http://www.flounder.com/iocompletion.htm
In addition, we were shown an alternative spin-lock implementation at the Microsoft Driver
Conference :-)
http://www.flounder.com/spinlock.htm
Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm