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.
+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>
}
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)
/* 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: