Allow threads to reopen after closing

This commit is contained in:
Paul Hollinsky
2018-11-16 17:08:53 -05:00
parent 0cf1e7fe7f
commit 07a5dc4118
7 changed files with 14 additions and 1 deletions
+2 -1
View File
@@ -31,8 +31,10 @@ void Communication::spawnThreads() {
}
void Communication::joinThreads() {
closing = true;
if(readTaskThread.joinable())
readTaskThread.join();
closing = false;
}
bool Communication::close() {
@@ -40,7 +42,6 @@ bool Communication::close() {
return false;
isOpen = false;
closing = true;
joinThreads();
return impl->close();
@@ -12,8 +12,10 @@ void MultiChannelCommunication::spawnThreads() {
}
void MultiChannelCommunication::joinThreads() {
closing = true;
if(mainChannelReadThread.joinable())
mainChannelReadThread.join();
closing = false;
}
bool MultiChannelCommunication::sendPacket(std::vector<uint8_t>& bytes) {