23 #ifndef ASYNCDISPATCHER_H
24 #define ASYNCDISPATCHER_H
38 boost::shared_future<
typename std::result_of<F()>::type>
schedule(
const F& task) {
39 std::lock_guard<std::mutex> lock(m_mutex);
40 auto prom =
std::make_shared<boost::promise<
typename std::result_of<F()>::type>>();
41 m_tasks.push_back([=]() { prom->set_value(task()); });
42 m_condition.notify_all();
43 return boost::shared_future<
typename std::result_of<F()>::type>(prom->get_future());
50 std::list<std::function<void()>> m_tasks;
51 std::list<std::thread> m_threads;
53 std::condition_variable m_condition;