How do I exhaust a thread's message queue?
Andrej Mitrovic
none at none.none
Fri Apr 1 19:34:51 PDT 2011
Note this is just pseudocode:
// worker thread
void doWork()
{
// while there's still stuff in the message queue
while (messagesInQueue)
{
result = receiveOnly!int();
switch(result)
{
// main thread could be enabling or disabling features this way,
// and sending some commands..
}
}
// now that we have all of our commands, do some hard work..
}
// background Thread
void main()
{
while (userHasMoreInputs())
{
// send switches to the worker thread, via e.g.:
workerThread.send(userValue);
}
}
So I'm really interested in how to implement that line:
while (messagesInQueue)
Perhaps I have to use receiveTimeout?
More information about the Digitalmars-d-learn
mailing list