File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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)
@@ -122,6 +124,7 @@ void Timer::stop()
122124
123125 if (mShowTimeMode == SHOWTIME_MODES::SHOWTIME_FILE) {
124126 const double sec = (double )diff / CLOCKS_PER_SEC;
127+ std::lock_guard<std::mutex> l (mCoutLock );
125128 std::cout << mStr << " : " << sec << " s" << std::endl;
126129 } else if (mShowTimeMode == SHOWTIME_MODES::SHOWTIME_FILE_TOTAL) {
127130 const double sec = (double )diff / CLOCKS_PER_SEC;
@@ -134,3 +137,5 @@ void Timer::stop()
134137
135138 mStopped = true ;
136139}
140+
141+ std::mutex Timer::mCoutLock ;
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ class CPPCHECKLIB Timer {
8888 std::clock_t mStart ;
8989 const SHOWTIME_MODES mShowTimeMode ;
9090 bool mStopped ;
91+ static std::mutex mCoutLock ;
9192};
9293// ---------------------------------------------------------------------------
9394#endif // timerH
You can’t perform that action at this time.
0 commit comments