Skip to content

Commit

Permalink
ATHREAD::FIXED:: Do not immediately run buffer/tanomaly threads at st…
Browse files Browse the repository at this point in the history
…artup
  • Loading branch information
frikilax committed May 17, 2021
1 parent 235eb84 commit f5246e1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions toolkit/AThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "AThread.hpp"
#include "Logger.hpp"

AThread::AThread(int interval) :
AThread::AThread(int interval) :
_interval(interval),
_thread(),
_is_stop(false) {}
Expand All @@ -21,14 +21,16 @@ void AThread::ThreadMain() {
std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);

while (!(this->_is_stop)) {
if (!this->Main()) {
DARWIN_LOG_DEBUG("AThread::ThreadMain:: Error in main function, stopping the thread");
_is_stop = true;
break;
}
while (not this->_is_stop) {
// Wait for notification or until timeout
this->_cv.wait_for(lck, std::chrono::seconds(_interval));
if (not _is_stop) {
if (not this->Main()) {
DARWIN_LOG_DEBUG("AThread::ThreadMain:: Error in main function, stopping the thread");
_is_stop = true;
break;
}
}
}
}

Expand Down

0 comments on commit f5246e1

Please sign in to comment.