From: Tom Tromey Date: Fri, 30 Apr 2021 16:04:56 +0000 (-0600) Subject: Use rvalue reference in thread_pool::post_task X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=698facb837c556b0e189b92563ec8bd4f2de373d;p=binutils-gdb.git Use rvalue reference in thread_pool::post_task Tankut's recent patches made me realize that thread_pool::post_task should have used an rvalue reference for its parameter. This patch makes this change. gdbsupport/ChangeLog 2021-04-30 Tom Tromey * thread-pool.cc (thread_pool::post_task): Update. * thread-pool.h (class thread_pool) : Take rvalue reference to function. --- 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: