summaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-04-30 10:04:56 -0600
committerTom Tromey <tromey@adacore.com>2021-04-30 10:04:56 -0600
commit698facb837c556b0e189b92563ec8bd4f2de373d (patch)
treee9bb1281cce15de55c73a53f5e9be0828139f99e /gdbsupport
parent2869ac4b59d58caf736f216f7bc65377116bd5f7 (diff)
downloadbinutils-gdb-698facb837c556b0e189b92563ec8bd4f2de373d.tar.gz
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 <tromey@adacore.com> * thread-pool.cc (thread_pool::post_task): Update. * thread-pool.h (class thread_pool) <post_task>: Take rvalue reference to function.
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog6
-rw-r--r--gdbsupport/thread-pool.cc4
-rw-r--r--gdbsupport/thread-pool.h2
3 files changed, 9 insertions, 3 deletions
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 <tromey@adacore.com>
+
+ * thread-pool.cc (thread_pool::post_task): Update.
+ * thread-pool.h (class thread_pool) <post_task>: Take rvalue
+ reference to function.
+
2021-04-27 Michael Weghorn <m.weghorn@posteo.de>
Simon Marchi <simon.marchi@polymtl.ca>
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<void>
-thread_pool::post_task (std::function<void ()> func)
+thread_pool::post_task (std::function<void ()> &&func)
{
- std::packaged_task<void ()> t (func);
+ std::packaged_task<void ()> t (std::move (func));
std::future<void> 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<void> post_task (std::function<void ()> func);
+ std::future<void> post_task (std::function<void ()> &&func);
private: