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?