How do I exhaust a thread's message queue?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Apr 2 11:03:05 PDT 2011


It turns out the receiveTimeout technique didn't work well for me. In
my case, there's a timer which spawns a high-priority thread calling
`foo` several hundred times per second. What I really needed is to
exhaust the message queue, and then do some other work after that. So
I've added a `shared int messagesInQueue`, which gets incremented in
the main thread, and decremented in the work thread when it reads off
those messages.

But isn't something like this already implemented somewhere in
core.thread or std.concurrency? All I want to do is check if there are
/any/ messages in queue for the current thread.


More information about the Digitalmars-d-learn mailing list