19 #include <condition_variable>
25 #include <type_traits>
53 for (std::size_t i = 0; i < N; ++i)
72 template<
class F,
class R=std::result_of_t<F&()> >
73 std::future<R>
queue(F&& f)
80 auto ptr = std::make_shared< std::packaged_task<R()> >(std::forward<F>(f));
81 auto taskFunc = [ptr]() {
if (ptr->valid()) (*ptr)(); };
83 auto r=ptr->get_future();
85 std::unique_lock<std::mutex> l(
m_mutex);
98 std::unique_lock<std::mutex> l(
m_mutex);
111 template <
typename ...Args>
120 std::function<void()> f;
123 std::unique_lock<std::mutex> l(
m_mutex);
141 std::condition_variable
m_cond;
144 std::deque< std::function<void()> >
m_work;