mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsTimer: add support for nano seconds
To enable nano mode, parameter is_nano must set to true.
This commit is contained in:
@@ -36,10 +36,11 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
CComponentsTimer::CComponentsTimer(const int& interval)
|
||||
CComponentsTimer::CComponentsTimer(const int& interval, bool is_nano)
|
||||
{
|
||||
tm_thread = 0;
|
||||
tm_interval = interval;
|
||||
tm_enable_nano = is_nano;
|
||||
|
||||
sl_stop_timer = sigc::mem_fun(*this, &CComponentsTimer::stopTimer);
|
||||
|
||||
@@ -59,7 +60,10 @@ void CComponentsTimer::runSharedTimerAction()
|
||||
while(tm_enable && tm_interval > 0) {
|
||||
tm_mutex.lock();
|
||||
OnTimer();
|
||||
mySleep(tm_interval);
|
||||
if (!tm_enable_nano)
|
||||
mySleep(tm_interval);
|
||||
else
|
||||
usleep((useconds_t)tm_interval);
|
||||
tm_mutex.unlock();
|
||||
}
|
||||
|
||||
@@ -142,10 +146,11 @@ bool CComponentsTimer::stopTimer()
|
||||
return false;
|
||||
}
|
||||
|
||||
void CComponentsTimer::setTimerInterval(const int& seconds)
|
||||
void CComponentsTimer::setTimerInterval(const int& interval, bool is_nano)
|
||||
{
|
||||
if (tm_interval == seconds)
|
||||
if (tm_interval == interval && tm_enable_nano == is_nano)
|
||||
return;
|
||||
|
||||
tm_interval = seconds;
|
||||
tm_enable_nano = is_nano;
|
||||
tm_interval = interval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user