C++ futures part 4: What if I want an immediate on-thread std::async?
cppdashboard.dev/r/2026/10/cpp-futures-part-4-what-if-i-want-an-immediate-on-thread-stdThis article discusses how to implement an immediate on-thread calculation using std::async in C++. It provides several methods to achieve this, including using promises and packaged tasks.
From the article
I noted last time that you are not allowed to ask std:: async for an immediate on-thread calculation. The C++ library designers probably chose not to support it because there’s no point: An immediate on-thread calculation is just a function call, so call the function already and leave me out of it.
But maybe you want to do it because you are interfacing with a component that wants a std:: future . How could you do it?
One way would be to implement the immediately synchronous case manually by setting a value into a promise.
Share this resource