Search⌘ K

Promise and Future: Return a Notification

Explore how promises and futures can be used to synchronize threads in C++ more simply and safely than condition variables. Understand their single-notification behavior, error handling, and avoidance of spurious wakeups. See examples of task-based thread communication using promise and future pairs for notification.

We'll cover the following...

If you use promises and futures to synchronize threads, they have a lot in common with condition variables. Most of the time, promises and futures are the better choices. Before I present you an example, here is the big picture.

Criteria Condition Variables Tasks
...