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 O’Reilly online learning.

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