mfc >> A new interthread queueing essay

by Joseph M. Newcomer » Sat, 22 Nov 2003 13:16:32 GMT

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


mfc >> A new interthread queueing essay

by Alexander Grigoriev » Sat, 22 Nov 2003 23:56:23 GMT


Do you want to sacrifice legacy (Win9x) support by using IOCP? Many of us
don't. It could be easily implemented by a private queue+Event (which is
what IOCP essentially is).



(the first units
do was come up
PostMessage, because
of data
base (some 40K
More seriously
a complex
the OnIdle
quantities) to
the PostMessage
Microsoft Driver





mfc >> A new interthread queueing essay

by Joseph M. Newcomer » Sun, 23 Nov 2003 17:43:30 GMT

I have no interest in supporting MS-DOS, and my client base has explicitly moved to a
minimum of Win2K. One client demands XP SP1, another demands Server 2003 as the *minimum*
system they can run on. So I no longer have to deal with obsolete operating systems. This
is very liberating. I have only one MS-DOS box, my old laptop, which I never, ever use for
development (it is a PowerPoint display engine) and I hope to replace that in the near
future (as soon as I can find a 3.5-lb laptop with VGA output, for example. Dell blew it
completely in this area--had they given me VGA output, I'd be running an XP laptop at this
point)

Besides, I already published an essay on using queues (but not events; that's a bad idea.
Semaphores are the correct implementation) so that is covered.
joe






Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm