Future and promise
The C++ tasks often behave like a data channel of sorts. The sending end, often called promise, sends data to a receiving end, often called the future. The important notion about futures and promises is that they enable a transfer of values between two tasks without the explicit use of a lock. The transfer of values is handled by the system (runtime) itself. The basic concept behind future and promise is simple; when a task wants to pass a value into another, it puts the value into a promise.
A standard library makes sure that the future associated with this promise gets this value. The other task can read this value from this future (the following diagram has to be read from the right to the left):
The future comes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access