lundi 7 mai 2018

How can a function run "as if" on a new thread without doing so?

Per [futures.async]/3 bullet 1 of the C++ Standard, when a function f is passed to std::async with the std::launch::async launch policy, f will run "as if in a new thread of execution".

Given that f can do anything, including loop infinitely and block forever, how can an implementation offer the behavior of f running on its own thread without actually running it on its own thread? That is, how can an implementation take advantage of the "as if" wiggle room the Standard provides?

Aucun commentaire:

Enregistrer un commentaire