diff options
author | 2016-06-21 09:41:06 +0300 | |
---|---|---|
committer | 2016-06-21 09:41:06 +0300 | |
commit | b4a17c0d02d500a9a08a052b958160791279c023 (patch) | |
tree | 2d745d97db94cc46c32b85510aae8c2c3f182bba /src | |
parent | 0422016ab056245449e0e5bdf0dceef2c4f06e31 (diff) |
WATCHDOG: reading the counter for the main loop is probably better with
a lock
Diffstat (limited to 'src')
-rw-r--r-- | src/trex_watchdog.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/trex_watchdog.cpp b/src/trex_watchdog.cpp index c72ce69e..d099933b 100644 --- a/src/trex_watchdog.cpp +++ b/src/trex_watchdog.cpp @@ -225,8 +225,10 @@ void TrexWatchDog::_main() { dsec_t now = now_sec(); - /* volatile are slow - read once per iteration */ + /* to be on the safe side - read the count with a lock */ + std::unique_lock<std::mutex> lock(m_lock); int count = m_mon_count; + lock.unlock(); for (int i = 0; i < count; i++) { TrexMonitor *monitor = m_monitors[i]; |