mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-03 19:01:25 +02:00
cc_timer: add member to get count of ticks
This commit is contained in:
@@ -45,6 +45,7 @@ CComponentsTimer::CComponentsTimer(const int64_t& interval)
|
|||||||
tm_thread_name = string();
|
tm_thread_name = string();
|
||||||
tm_interval = interval;
|
tm_interval = interval;
|
||||||
tm_enable = false;
|
tm_enable = false;
|
||||||
|
tm_ticks = 0;
|
||||||
sl_cleanup_timer = sigc::mem_fun(*this, &CComponentsTimer::stopThread);
|
sl_cleanup_timer = sigc::mem_fun(*this, &CComponentsTimer::stopThread);
|
||||||
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl_cleanup_timer);
|
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl_cleanup_timer);
|
||||||
CNeutrinoApp::getInstance()->OnShutDown.connect(sl_cleanup_timer);
|
CNeutrinoApp::getInstance()->OnShutDown.connect(sl_cleanup_timer);
|
||||||
@@ -78,6 +79,7 @@ void CComponentsTimer::threadCallback(CComponentsTimer *tm)
|
|||||||
int64_t i = 0;
|
int64_t i = 0;
|
||||||
|
|
||||||
TIMER_START();
|
TIMER_START();
|
||||||
|
tm->tm_ticks = 0;
|
||||||
while(tm->tm_enable) //exit loop handled in destructor
|
while(tm->tm_enable) //exit loop handled in destructor
|
||||||
{
|
{
|
||||||
if (tm->tm_interval > 0)
|
if (tm->tm_interval > 0)
|
||||||
@@ -96,6 +98,7 @@ void CComponentsTimer::threadCallback(CComponentsTimer *tm)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tm->tm_ticks ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dprintf(DEBUG_DEBUG,"\033[32m[CComponentsTimer] thread [%p] [%s] [%s - %d] loop/callback finished\033[0m\n ", tm->tm_thread, tm->tn.c_str(), __func__, __LINE__);
|
dprintf(DEBUG_DEBUG,"\033[32m[CComponentsTimer] thread [%p] [%s] [%s - %d] loop/callback finished\033[0m\n ", tm->tm_thread, tm->tn.c_str(), __func__, __LINE__);
|
||||||
@@ -124,7 +127,7 @@ void CComponentsTimer::stopThread()
|
|||||||
delete tm_thread;
|
delete tm_thread;
|
||||||
tm_thread = NULL;
|
tm_thread = NULL;
|
||||||
tn.clear();
|
tn.clear();
|
||||||
dprintf(DEBUG_DEBUG,"\033[32m[CComponentsTimer] thread [%p] [%s] [%s - %d] thread object terminated\033[0m\n", tm_thread, tn.c_str(), __func__, __LINE__);
|
dprintf(DEBUG_DEBUG,"\033[32m[CComponentsTimer] thread [%p] [%s] [%s - %d] thread object terminated after %lu ticks\033[0m\n", tm_thread, tn.c_str(), __func__, __LINE__, tm_ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ class CComponentsTimer : public sigc::trackable
|
|||||||
|
|
||||||
///refresh interval in seconds
|
///refresh interval in seconds
|
||||||
int64_t tm_interval;
|
int64_t tm_interval;
|
||||||
|
int64_t tm_ticks;
|
||||||
|
|
||||||
///runs shared timer action provided inside OnTimer() signal
|
///runs shared timer action provided inside OnTimer() signal
|
||||||
static void threadCallback(CComponentsTimer *tm);
|
static void threadCallback(CComponentsTimer *tm);
|
||||||
|
Reference in New Issue
Block a user