c++multithreading

Do std::async and std::future use mutexes and a condition variable under the hood?


I've been led to believe that using std::async with the returned future is basically just a simplified way of using mutexes, where the actual handling of the new std::thread and the locking/unlocking of the mutex is abstracted away by the async function and the future.

I'm fairly new to multi-threading concepts - is this the case? Am I understanding something incorrectly?

Edit: I left out that this abstraction would obviously make use of an std::condition_variable


Solution

  • Maybe.

    It's up to the implementer. They can do it with std::mutex and std::condition_variable, or with the underlying components with which they implemented those, or with some other scheme.

    The standard prescribes the observable behaviour, not the implementation.