30 lines
447 B
C++
30 lines
447 B
C++
#include "Utils/Thread.hpp"
|
|
|
|
namespace Chattr {
|
|
|
|
Thread::Thread(Thread&& other) noexcept {
|
|
other.detach();
|
|
memcpy(this, &other, sizeof(Thread));
|
|
}
|
|
|
|
Thread& Thread::operator=(Thread&& other) noexcept {
|
|
other.detach();
|
|
memcpy(this, &other, sizeof(Thread));
|
|
return *this;
|
|
}
|
|
|
|
Thread::~Thread() {
|
|
if (!detached) {
|
|
spdlog::critical("There is not joined thread");
|
|
std::exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
void Thread::detach() {
|
|
detached = true;
|
|
}
|
|
|
|
}
|
|
|
|
|