41. Concurrency

Keep it simple:

as simple as possible,

but no simpler.

– A. Einstein

Introduction

Memory Model

Memory Location; Instruction Reordering; Memory Order; Data Races

Atomics

atomic Types; Flags and Fences

volatile

Advice

41.1. Introduction

Concurrency – the execution of several tasks simultaneously – is widely used to improve throughput (by using several processors for a single computation) or to improve responsiveness (by allowing one part of a program to progress while another is waiting for a response).

The C++ standard support for concurrency is introduced in a tutorial manner in §5.3. This chapter and the next provide a more detailed and systematic view.

We call an activity potentially executed concurrently with other ...

Get The C++ Programming Language, 4th Edition 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.