임시저장(빌드 안됨) 졸려서 자러갈거야
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user