diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index 2b575ea3118..72802c66c56 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,3 +1,9 @@ +2021-04-30 Tom Tromey + + * thread-pool.cc (thread_pool::post_task): Update. + * thread-pool.h (class thread_pool) : Take rvalue + reference to function. + 2021-04-27 Michael Weghorn Simon Marchi diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc index cd5e11673a9..2bb75cc9cef 100644 --- a/gdbsupport/thread-pool.cc +++ b/gdbsupport/thread-pool.cc @@ -130,9 +130,9 @@ thread_pool::set_thread_count (size_t num_threads) } std::future -thread_pool::post_task (std::function func) +thread_pool::post_task (std::function &&func) { - std::packaged_task t (func); + std::packaged_task t (std::move (func)); std::future f = t.get_future (); if (m_thread_count == 0) diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h index b28b74647c5..9bddaa9eaae 100644 --- a/gdbsupport/thread-pool.h +++ b/gdbsupport/thread-pool.h @@ -58,7 +58,7 @@ public: /* Post a task to the thread pool. A future is returned, which can be used to wait for the result. */ - std::future post_task (std::function func); + std::future post_task (std::function &&func); private: