Skip to content
Snippets Groups Projects

have an additional sync variable

Merged Juergen Hannappel requested to merge threadingFix into controller
1 file
+ 4
1
Compare changes
  • Side-by-side
  • Inline
+ 4
1
@@ -24,6 +24,8 @@ static std::condition_variable syncCvToMain;
static std::mutex syncMutexToWorker;
static std::condition_variable syncCvToWorker;
static std::atomic<unsigned> nArmed(0);
static std::atomic<bool> mayStart(false);
static std::atomic<std::chrono::system_clock::time_point> lastThreadEnd(std::chrono::system_clock::time_point::min());
static std::atomic<unsigned long long> totalBytesWritten(0);
@@ -45,7 +47,7 @@ void worker(const std::string& dataHandlerName,
}
{
std::unique_lock<decltype(syncMutexToWorker)> lock(syncMutexToWorker);
syncCvToWorker.wait(lock);
syncCvToWorker.wait(lock, []{return mayStart.load();});
}
auto timingGenerator = timing::base::newHandler(timingHandlerName, threadNo);
@@ -140,6 +142,7 @@ int main(int argc, const char*argv[]) {
}
{
std::unique_lock<decltype(syncMutexToWorker)> lock(syncMutexToWorker);
mayStart = true;
syncCvToWorker.notify_all();
}
auto firstThreadStart = std::chrono::system_clock::now();
Loading