Boost:future :: then with launch :: deferred policy with async with launch :: async policy

时间:2017-09-13 07:44:34

标签: c++ multithreading asynchronous boost

假设我们有从主线程调用的代码:

boost::future<int> fi = boost::async(boost::launch::async, boost::bind(fun, arg));
boost::future<void> on_finish = fi.then(boost::launch::deferred, [](auto fut) {
    auto res = fut.get();
    ...
});

函数fun具有正文:

int fun(int arg)
{
    int res;
    ...
    return res;
}

1。工作将如何进行?如果主线程纯粹异步工作,那么在其他线程中执行then之后,是否会在主线程中从fun继续调用lambda?
2.如果主线程一直忙,将会发生什么,例如通过循环无限循环?那么then延续不会被执行吗?

0 个答案:

没有答案