File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 2323#include < utility>
2424#include < vector>
2525
26+ // TODO: print through a synchronized logger
27+
2628namespace {
2729 using dataElementType = std::pair<std::string, struct TimerResultsData >;
2830 bool more_second_sec (const dataElementType& lhs, const dataElementType& rhs)
@@ -113,6 +115,7 @@ void Timer::stop()
113115
114116 if (mShowTimeMode == SHOWTIME_MODES::SHOWTIME_FILE) {
115117 const double sec = (double )diff / CLOCKS_PER_SEC;
118+ std::lock_guard<std::mutex> l (mCoutLock );
116119 std::cout << mStr << " : " << sec << " s" << std::endl;
117120 } else {
118121 if (mTimerResults )
@@ -122,3 +125,5 @@ void Timer::stop()
122125
123126 mStopped = true ;
124127}
128+
129+ std::mutex Timer::mCoutLock ;
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ class CPPCHECKLIB Timer {
8686 std::clock_t mStart ;
8787 const SHOWTIME_MODES mShowTimeMode ;
8888 bool mStopped ;
89+ static std::mutex mCoutLock ;
8990};
9091// ---------------------------------------------------------------------------
9192#endif // timerH
You can’t perform that action at this time.
0 commit comments