Here comes he RunT!

This commit is contained in:
2026-02-20 23:40:15 -08:00
parent 88d989f9cd
commit aaf4596217
36 changed files with 11508 additions and 416 deletions

View File

@ -0,0 +1,25 @@
#pragma once
#include "thread_pool.h"
#include <memory>
#include <mutex>
class GlobalThreadPool {
private:
static std::unique_ptr<ThreadPool> instance_;
static std::once_flag initialized_;
public:
static ThreadPool& getInstance() {
std::call_once(initialized_, []() {
unsigned int hw_threads = std::thread::hardware_concurrency();
size_t num_threads = hw_threads > 4 ? hw_threads / 2 : 2;
instance_ = std::make_unique<ThreadPool>(num_threads);
});
return *instance_;
}
static void shutdown() {
instance_.reset();
}
};