the behavior of std::async with std::launch::async policy

前端 未结 1 1190
盖世英雄少女心
盖世英雄少女心 2021-02-12 23:15

I have some question about behavior of std::async function with std::launch::async policy & std::future object returned from async.

相关标签:
1条回答
  • 2021-02-12 23:58

    Yes, this is required by the C++ Standard. 30.6.8 [futures.async] paragraph 5, final bullet:

    — the associated thread completion synchronizes with (1.10) the return from the first function that successfully detects the ready status of the shared state or with the return from the last function that releases the shared state, whichever happens first.

    The destructor of the one and only std:future satisfies that condition, and so has to wait for the completion of the thread.

    0 讨论(0)
提交回复
热议问题