비트 딱 맞는지 리눅스에서도 확인할 것

This commit is contained in:
2025-05-01 10:44:45 +09:00
parent 9451b4da40
commit d3161edb36
8 changed files with 88 additions and 29 deletions

View File

@@ -3,7 +3,22 @@
namespace Chattr {
ThreadPool::ThreadPool() {
}
ThreadPool::ThreadPool(std::uint32_t numThreads) {
init(numThreads);
}
ThreadPool::~ThreadPool() {
terminate_ = true;
jobQueueCV_.notify_all();
for (auto& t : workers_)
t.join();
}
void ThreadPool::init(std::uint32_t numThreads) {
int numCPU = numThreads;
if (numThreads == 0) {
#ifdef _WIN32
@@ -22,14 +37,6 @@ ThreadPool::ThreadPool(std::uint32_t numThreads) {
workers_.push_back([this]() { this->Worker(); });
}
ThreadPool::~ThreadPool() {
terminate_ = true;
jobQueueCV_.notify_all();
for (auto& t : workers_)
t.join();
}
void* ThreadPool::Worker() {
#ifdef _WIN32
DWORD pid = GetCurrentThreadId();