Futures and Promises
suggest changeVersions
Introduction
Promises and futures pass one result, either a value or an exception, from the producer to the consumer. Those two sides are often different threads, but they do not have to be.
A std::promise is set by the code that produces the result.
A std::future retrieves that result with get(), which rethrows a stored exception. wait(), wait_for(), and wait_until() block until the result is ready. valid() only reports whether the future refers to a shared state; it does not report whether that state is ready.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents