如何将boost :: async()与调度程序生成的执行程序包装一起使用?

时间:2017-04-17 00:50:57

标签: c++ boost boost-thread

使用以下代码:

boost::basic_thread_pool e;
boost::scheduler<Clock> scheduler;
auto wrapper = scheduler.on(e);

// test run after

auto executorAfter2Seconds = wrapper.after(boost::chrono::seconds(2));
boost::async(executorAfter2Seconds, []() { return 10; }); // leads to an error: no member named 'try_executing_one' in boost::executors::resubmit_at_executor<....>

我收到了评论的错误。当我手动调用提交时,传递一个promise并设置future的值:

boost::promise<int> p0;
auto f0 = p0.get_future();
executorAfter2Seconds.submit([&p0](){ p0.set_value(10); });

它没有问题。如何将预定的执行程序传递给boost :: async()?

0 个答案:

没有答案