mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
tasklets test: guard against garbled output
Use a mutex to ensures that only a single prints at the same time. this should prevent garbled terminal output and thus makes the it much easier to read. on the flipside, some race conditions may go unnoticed.
This commit is contained in:
parent
5c9e20c00e
commit
25e952fb49
@ -33,6 +33,8 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
std::mutex outputMutex;
|
||||
|
||||
Ewoms::TaskletRunner *runner;
|
||||
|
||||
class SleepTasklet : public Ewoms::TaskletInterface
|
||||
@ -49,7 +51,9 @@ public:
|
||||
{
|
||||
assert(0 <= runner->workerThreadIndex() && runner->workerThreadIndex() < runner->numWorkerThreads());
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(mseconds_));
|
||||
outputMutex.lock();
|
||||
std::cout << "Sleep tasklet " << n_ << " of " << mseconds_ << " ms completed by worker thread " << runner->workerThreadIndex() << std::endl;
|
||||
outputMutex.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user