FOMO Daily
Feed
Raymond Chenยท

C++ futures part 2: The mental model for std::promise, std::packaged_task

Languages & ToolingC++FuturesConcurrency

TL;DR

C++ futures are easier to understand when you view them as handles to shared state holding a result or exception. A std::promise fills that state directly, while std::packaged_task stores a callable and fills it when invoked, letting a future retrieve the outcome later.

Relevant links

Sign in to save links
Read the original post Sign in to mark as read or skip