Skip to main content

Example

A composite task queue is a task queue that’s made up of parts from other queues. Composite task queues are useful when one asynchronous task needs to call another, and the completion from that task is an intermediate step that shouldn’t waste cycles on the completion thread. In this case, a composite queue can be created. The work and completion ports of this composite queue both use the work port of the original queue. The following example uses the thread pool for work but integrates completion port callbacks into a Win32 WindowProc callback function. This example also demonstrates the correct termination of a task queue when you’re integrating it with another threading model.
Another technique for this is to create a local queue whose work and completion dispatch types are immediate. An immediate dispatch mode doesn’t involve any asynchronous activity at all - it dispatches callbacks as soon as they’re submitted as shown in the following code example.

See also

Designing the task queue
Last modified on August 4, 2026