Chapter 6

Event Synchronization

Abstract

This chapter is concerned with event synchronization, namely, how to force a thread to wait for an event triggered by another thread. A detailed pedagogical discussion of the event synchronization primitives in Pthreads, Windows, and C++11 is presented, underlining their common structure. The role of condition variables as communication agents between threads is discussed in detail. A couple of examples dealing with high-level synchronization constructs demonstrate some subtle aspects of their operation. Then, some additional event synchronization constructs—futures and promises—introduced in the C++11 thread library are reviewed, because they constitute powerful and easy-to-use tools for application ...

Get Shared Memory Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.