Device: Fix heartbeat thread join location

This commit is contained in:
Yasser Yassine
2025-02-19 05:15:23 +00:00
committed by Kyle Schwarz
parent fb5c4babce
commit d4995fa2a9
2 changed files with 25 additions and 24 deletions
+4 -5
View File
@@ -37,29 +37,28 @@ bool Communication::open() {
}
void Communication::spawnThreads() {
closing = false;
readTaskThread = std::thread(&Communication::readTask, this);
}
void Communication::joinThreads() {
closing = true;
if(pauseReadTask) {
resumeReads();
}
closing = true;
if(readTaskThread.joinable())
readTaskThread.join();
closing = false;
}
bool Communication::close() {
joinThreads();
if(!isOpen() && !isDisconnected()) {
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
return false;
}
joinThreads();
return driver->close();
}