Promise and Future: Returning a Notification
Explore how promises and futures in C++ provide a safer and simpler way to synchronize threads compared to condition variables. Understand their advantages such as one-time notifications, lack of locks, and built-in error handling. This lesson helps you implement clean thread communication with tasks using promises and futures before advancing to shared futures.
We'll cover the following...
We'll cover the following...
If we 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 we present an example, here is the big picture.
| Criteria | Condition Variables |
|---|