Understanding a message queue

To understand message passing better, let's review the message queue. Every top-level window has its own message queue that is created by the operating system. In a multitasking environment, there are many applications executed at the same time with a lot of windows displayed on the user's screen. The operating system is processing a very large number of messages, handling various events raised from the system itself, and running various applications. At the same time, the user is pressing keyboard keys, clicking the mouse, or swiping the touch screen.

To demonstrate message passing along with the queue operations, let's review the following example. Let's assume that we need to perform complex drawings represented ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.