임시저장(빌드 안됨) 졸려서 자러갈거야

This commit is contained in:
2025-04-29 21:49:58 +09:00
parent 1c6404530d
commit 1703974310
8 changed files with 167 additions and 17 deletions

View File

@@ -1,17 +1,30 @@
#include "Utils/Thread.hpp"
namespace Chattr {
Thread::~Thread() {
if (!detached)
join();
Thread::Thread(Thread&& other) noexcept {
other.detach();
}
void Thread::join() {
Thread& Thread::operator=(Thread&& other) noexcept {
other.detach();
return *this;
}
Thread::~Thread() {
if (!detached) {
spdlog::critical("There is not joined thread");
std::exit(EXIT_FAILURE);
}
}
void* Thread::join() {
#ifdef _WIN32
WaitForSingleObject(handle_, INFINITE);
#elif __linux__
pthread_join(handle_, NULL);
pthread_join(handle_, returnValue);
#endif
return returnValue;
}
void Thread::detach() {