Thread 고치기

This commit is contained in:
USW
2025-04-30 12:01:37 +09:00
parent 89633f94a2
commit cebd6bb9e9
4 changed files with 42 additions and 24 deletions

View File

@@ -16,15 +16,8 @@ Thread::~Thread() {
spdlog::critical("There is not joined thread");
std::exit(EXIT_FAILURE);
}
}
void* Thread::join() {
#ifdef _WIN32
WaitForSingleObject(handle_, INFINITE);
#elif __linux__
pthread_join(handle_, returnValue);
#endif
return returnValue;
if (returnValuePtr != nullptr)
delete returnValuePtr;
}
void Thread::detach() {

View File

@@ -7,7 +7,7 @@ ThreadPool::ThreadPool(std::uint32_t numThreads) {
workers_.reserve(numThreads);
while (numThreads--)
workers_.push_back([this]() -> void* { return this->Worker(); });
workers_.push_back([this]() -> int { this->Worker(); return 1; });
}
ThreadPool::~ThreadPool() {
@@ -24,7 +24,6 @@ void* ThreadPool::Worker() {
#elif __linux__
pid_t pid = getpid();
#endif
spdlog::info("ThreadPool Worker : {}", pid);
while (!terminate_) {
std::unique_lock<std::mutex> lock(jobQueueMutex);
spdlog::info("ThreadPool Worker : {} Waiting for a job", pid);