In an earlier tutorial we briefly introduced ACE_Message_Queue. In this tutorial we'll go into a bit more detail.
ACE_Message_Queue is modeled after Unix System V IPC mechanisms. The basic idea is that you put a block of data into one end of the Queue and take it out of the other end. Your basic FIFO in other words. The SysV mechanism works great for passing these blocks of data between processes on the same host but it's a bit overkill for moving blocks between threads. You could use a pipe, socket or similar mechanism but that still has more overhead than we really want just for moving data between threads. Process-global memory is a good technique but then you need a way to signal the "listening" threads. The ACE_Message_Queue is a better approach: Create blocks of data and enqueue them in one thread while another thread (or threads) dequeue and perform work.
Kirthika's Abstract:
The Message Queue consists of Message Blocks, each of which has a read and write pointer. Using these pointers the message blocks can be accessed for reading and writing operations. The ACE_Task::svc() method will put the block onto the queue without bothering about the existence of a consumer for that block. A thread from the thread pool obtains the block from the queue, and checks to see whether the block_type is MB_HANGUP. If so, it puts the block back on the queue for its peers and exits. Otherwise, it reads the block and processes it before releasing it.
This simple tutorial makes us aware of the usage and importance of the Message Queue which could be used to our advantage especially for multithreaded applications.