1 #include "async_pool.h"
5 AsyncPool& STG::AsyncPoolST::instance()
11 void AsyncPool::start()
13 if (m_thread.joinable())
15 m_thread = std::jthread([this](auto token){ run(std::move(token)); });
18 void AsyncPool::stop()
20 if (!m_thread.joinable())
22 m_thread.request_stop();
26 void AsyncPool::run(std::stop_token token) noexcept
32 std::unique_lock lock(m_mutex);
33 m_cond.wait(lock, [this, &token](){ return !m_tasks.empty() || token.stop_requested(); });
34 if (token.stop_requested())
39 for (const auto& t : tasks)