Skip to content

Commit 5912511

Browse files
Updated Timer class to ManualResetEvent based wait operation
1 parent adae87a commit 5912511

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/lib/Timer.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//******************************************************************************************************
2323

2424
#include "Timer.h"
25+
#include "ManualResetEvent.h"
2526

2627
using namespace std;
2728
using namespace sttp;
@@ -40,15 +41,8 @@ void Timer::TimerThread()
4041

4142
if (interval > 0)
4243
{
43-
static constexpr int32_t MaxSleepDuration = 500;
44-
const int32_t waits = interval / MaxSleepDuration;
45-
const int32_t remainder = interval % MaxSleepDuration;
46-
47-
for (int32_t i = 0; i < waits && m_running; i++)
48-
ThreadSleep(MaxSleepDuration);
49-
50-
if (remainder > 0 && m_running)
51-
ThreadSleep(remainder);
44+
ManualResetEvent handle;
45+
handle.Wait(interval);
5246
}
5347
}
5448
catch (boost::thread_interrupted&)

0 commit comments

Comments
 (0)