He said that he was thread::join()synchronizing with the completion of the corresponding thread of execution. I am wondering if this applies to async()and future::wait(). For example:
std::atomic_int v(0);
std::async(
std::launch::async,
[&v] { v.fetch_add(1, std::memory_order_relaxed); }
).wait();
assert(v.load(std::memory_order_relaxed) == 1);
assert() will never work.
source
share