新增全局线程池, 更新线程池注释

This commit is contained in:
Nanako 2025-01-05 22:27:47 +08:00
parent c59daeaa92
commit 3d811d3b20

View File

@ -11,11 +11,34 @@
#include "containers/safe_vector.h"
class queued_thread_pool {
public:
explicit queued_thread_pool(size_t num_threads = std::thread::hardware_concurrency());
/**
* @brief 线
* @param num_threads 线线, CPU 1, 线
*/
explicit queued_thread_pool(size_t num_threads = std::thread::hardware_concurrency() - 1);
~queued_thread_pool();
/**
* @brief 线
* @return 线
*/
static queued_thread_pool& global() {
static queued_thread_pool instance;
return instance;
}
/**
* @brief 线
* @tparam F
* @tparam Args
* @param in_func
* @param in_args
* @return std::future
* @code
* auto res = thread_pool.submit([](int a, int b) { return a + b; }, 1, 2);
* @endcode
*/
template<typename F, typename... Args>
auto submit(F&& in_func, Args&&... in_args) {
using return_type = std::invoke_result_t<F, Args...>;