Used std::atomic for ThreadState

This commit is contained in:
Nav
2023-05-25 23:16:30 +01:00
parent 9475a80cd0
commit 4485ee0961
8 changed files with 23 additions and 31 deletions

View File

@@ -32,12 +32,12 @@ namespace Bloom
}
Logger::info("Shutting down SignalHandler");
Thread::setThreadState(ThreadState::STOPPED);
this->threadState = ThreadState::STOPPED;
}
void SignalHandler::startup() {
this->setName("SH");
Thread::setThreadState(ThreadState::STARTING);
this->threadState = ThreadState::STARTING;
Logger::debug("Starting SignalHandler");
// Block all signal interrupts
auto signalSet = this->getRegisteredSignalSet();
@@ -54,9 +54,9 @@ namespace Bloom
std::bind(&SignalHandler::triggerApplicationShutdown, this)
));
// It's possible that the SignalHandler has been instructed to shutdown, before it could finish starting up.
// It's possible that the SignalHandler has been instructed to shut down, before it could finish starting up.
if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) {
Thread::setThreadState(ThreadState::READY);
this->threadState = ThreadState::READY;
}
}

View File

@@ -22,7 +22,7 @@ namespace Bloom
* Triggers the shutdown of the SignalHandler thread.
*/
void triggerShutdown() {
this->setThreadState(ThreadState::SHUTDOWN_INITIATED);
this->threadState = ThreadState::SHUTDOWN_INITIATED;
};
private: