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

@@ -80,14 +80,12 @@ namespace Bloom::DebugServer
}
void DebugServerComponent::shutdown() {
if (
this->getThreadState() == ThreadState::STOPPED
|| this->getThreadState() == ThreadState::SHUTDOWN_INITIATED
) {
const auto threadState = this->getThreadState();
if (threadState == ThreadState::STOPPED || threadState == ThreadState::SHUTDOWN_INITIATED) {
return;
}
this->setThreadState(ThreadState::SHUTDOWN_INITIATED);
this->threadState = ThreadState::SHUTDOWN_INITIATED;
Logger::info("Shutting down DebugServer");
if (this->server) {
@@ -101,7 +99,7 @@ namespace Bloom::DebugServer
}
void DebugServerComponent::setThreadStateAndEmitEvent(ThreadState state) {
Thread::setThreadState(state);
this->threadState = state;
EventManager::triggerEvent(
std::make_shared<Events::DebugServerThreadStateChanged>(state)
);