mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 00:41:09 +02:00
CComponentsTimer: add slot for auto timer start/stop
Connection with OnBeforeRestart ensures closing threads.
Under certain circumstances, eg. running thread, a restart could fail.
Origin commit data
------------------
Branch: ni/coolstream
Commit: 28ef6e147e
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-09-26 (Fri, 26 Sep 2014)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -40,6 +40,8 @@ CComponentsTimer::CComponentsTimer( const int& interval)
|
|||||||
{
|
{
|
||||||
tm_thread = 0;
|
tm_thread = 0;
|
||||||
tm_interval = interval;
|
tm_interval = interval;
|
||||||
|
|
||||||
|
sl = sigc::mem_fun(*this, &CComponentsTimer::stopTimer);
|
||||||
startTimer();
|
startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +83,9 @@ bool CComponentsTimer::startTimer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval);
|
dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval);
|
||||||
|
|
||||||
|
//ensure kill of thread on any restart of neutrino
|
||||||
|
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +104,8 @@ bool CComponentsTimer::stopTimer()
|
|||||||
}
|
}
|
||||||
if (thres == 0){
|
if (thres == 0){
|
||||||
tm_thread = 0;
|
tm_thread = 0;
|
||||||
|
//ensure disconnect of unused slot
|
||||||
|
sl.disconnect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,8 @@ class CComponentsTimer : public sigc::trackable
|
|||||||
static void* initTimerThread(void *arg);
|
static void* initTimerThread(void *arg);
|
||||||
///mutex for timer
|
///mutex for timer
|
||||||
OpenThreads::Mutex mutex;
|
OpenThreads::Mutex mutex;
|
||||||
|
///slot for signals
|
||||||
|
sigc::slot0<bool> sl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///class constructor, parameter interval sets the interval in seconds, default value=1 (1 sec)
|
///class constructor, parameter interval sets the interval in seconds, default value=1 (1 sec)
|
||||||
|
Reference in New Issue
Block a user