|
|
|
@ -7,7 +7,7 @@
|
|
|
|
|
#include <string.h> // strerror
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct sigaction& sigActionCtor(struct sigaction &sigAct, const int signal)
|
|
|
|
|
struct sigaction& sigActionInit( struct sigaction &sigAct, const int signal )
|
|
|
|
|
{
|
|
|
|
|
sigAct.sa_flags = SA_SIGINFO;
|
|
|
|
|
sigemptyset( &sigAct.sa_mask );
|
|
|
|
@ -19,7 +19,7 @@ struct sigaction& sigActionCtor(struct sigaction &sigAct, const int signal)
|
|
|
|
|
|
|
|
|
|
Timer::Timer( const Timer& timer )
|
|
|
|
|
: m_signal( timer.m_signal )
|
|
|
|
|
, m_sigAction(sigActionCtor( m_sigAction , m_signal ) )
|
|
|
|
|
, m_sigAction( sigActionInit( m_sigAction , m_signal ) )
|
|
|
|
|
, m_timerId( 0 )
|
|
|
|
|
, m_periodic( false )
|
|
|
|
|
, m_running( true )
|
|
|
|
@ -40,10 +40,7 @@ void Timer::createTimer(const time_t interval_sec,
|
|
|
|
|
sigev.sigev_notify = SIGEV_SIGNAL;
|
|
|
|
|
sigev.sigev_signo = m_signal;
|
|
|
|
|
sigev.sigev_value.sival_ptr = &m_timerId;
|
|
|
|
|
if ( timer_create( CLOCK_MONOTONIC, &sigev, &m_timerId ) == -1 ) {
|
|
|
|
|
LOG ( Logger::FINEST, "Error from timer_create: " /*strerror(errno)*/ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
timer_create( CLOCK_MONOTONIC, &sigev, &m_timerId );
|
|
|
|
|
|
|
|
|
|
// arm it
|
|
|
|
|
struct itimerspec its;
|
|
|
|
@ -53,11 +50,7 @@ void Timer::createTimer(const time_t interval_sec,
|
|
|
|
|
its.it_interval.tv_nsec = initExpr_nsec;
|
|
|
|
|
|
|
|
|
|
if ( initExpr_sec != 0 or initExpr_nsec != 0 ) m_periodic = true;
|
|
|
|
|
|
|
|
|
|
if ( timer_settime( m_timerId, 0, &its, 0 ) == -1 ) {
|
|
|
|
|
LOG ( Logger::FINEST, "Error from timer_settime: " /*strerror(errno)*/ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
timer_settime( m_timerId, 0, &its, 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,10 +92,17 @@ void Timer::gracefulStop()
|
|
|
|
|
|
|
|
|
|
Timer::Timer( const int signal )
|
|
|
|
|
: m_signal( signal )
|
|
|
|
|
, m_sigAction(sigActionCtor( m_sigAction , m_signal ) )
|
|
|
|
|
, m_sigAction( sigActionInit( m_sigAction , m_signal ) )
|
|
|
|
|
, m_timerId( 0 )
|
|
|
|
|
, m_periodic( false )
|
|
|
|
|
, m_running( true )
|
|
|
|
|
{
|
|
|
|
|
TRACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Timer& Timer::operator=( const Timer& )
|
|
|
|
|
{
|
|
|
|
|
TRACE;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|