Previously if we received an rvalue function object we would call a
moved-from object on all but the first thread. In practice this didn't
cause an issue, but only because of the functions we were passing.
Fixes: https://tracker.ceph.com/issues/76094
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
#define CEPH_COMMON_ASYNC_CONTEXT_POOL_H
#include <concepts>
-#include <cstddef>
#include <cstdint>
#include <mutex>
#include <optional>
}
template<std::invocable<> Init>
io_context_pool(std::int64_t threadcnt, Init&& init) noexcept {
- start(threadcnt, std::move(init));
+ start(threadcnt, std::forward<Init>(init));
}
~io_context_pool() {
stop();
ioctx.restart();
for (std::int16_t i = 0; i < threadcnt; ++i) {
threadvec.emplace_back(make_named_thread("io_context_pool",
- [this, init=std::move(init)] {
- std::move(init)();
+ [this, init] {
+ init();
ioctx.run();
}));
}