Article

std::call_once vs. std::async

The Old New Thing ·The Old New Thing ·Published 2026-09-17 ·5 min read

This article discusses the differences between std::call_once and std::async in C++, focusing on how std::async can be used for deferred execution. It explains the behavior of std::future and std::shared_future in managing deferred tasks.

From the article

Last time, we compared magic statics with std::call_once and concluded that std::call_once lets you construct magic statics-like behavior for non-static variables.

But there is also std::async for delayed execution. Can we use that instead?

The idea here is that you tell std::async that you want it to defer execution of something (say, a lambda). It returns a std::future representing that deferred execution.


Share this resource


Discovered 2026-09-18 Source The Old New Thing Archive 2026-09 →