mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-24 02:24:46 +08:00
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.
This commit is contained in:
parent
2869ac4b59
commit
698facb837
@ -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>
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user