coding style fixes

master
Denes Matetelki 14 years ago
parent b328c6f9dd
commit 6792784464

@ -27,7 +27,8 @@ public:
* If currently locked, the call shall return immediately.
* @returns Zero if a lock acquired. Otherwise, an error number.
*/
int tryLock(const long int intervalSec = 0, const long int intervalNSec = 0);
int tryLock( const long int intervalSec = 0,
const long int intervalNSec = 0 );
pthread_mutex_t* getPThreadMutex();

@ -10,13 +10,11 @@ class Timer
public:
Timer( const int signal = SIGALRM );
virtual ~Timer() {}
virtual ~Timer() {}
virtual void timerExpired() {}
virtual void periodicTimerExpired() {}
void createTimer( const time_t interval_sec,
const long interval_nsec = 0,
const time_t initExpr_sec = 0,
@ -34,7 +32,7 @@ private:
// data members (time_t, which is an int by the way) so copy ctor and
// assign op shall be inmplemented
Timer( const Timer& timer );
Timer& operator=(const Timer&) { return *this; }
Timer& operator=( const Timer& );
int m_signal;
struct sigaction m_sigAction;

@ -14,8 +14,8 @@ class TimerUser
public:
virtual void timerExpired( void ) = 0;
virtual void timerDestroyed( void ) = 0;
virtual void timerExpired() = 0;
virtual void timerDestroyed() = 0;
virtual ~TimerUser() {}
@ -46,7 +46,7 @@ public:
void addTimerUser( TimerUser* user,
const timespec expiration,
const timespec periodTime = timespec_ctor() );
const timespec periodTime = timespec_init() );
bool removeTimerUser( TimerUser* timerUser );
@ -58,10 +58,10 @@ private:
void notifyAndRemove( const timespec t );
void* run( void );
void* run();
// ctor function
inline static timespec timespec_ctor() {
// init function
inline static timespec timespec_init() {
timespec tmp = { 0, 0 };
return tmp;
};

@ -1,9 +1,10 @@
#include "Mutex.hpp"
#include "Common.hpp"
#include "Common.hpp"
#include <time.h>
pthread_mutex_t& MutexCtor( pthread_mutex_t& mutex )
{
pthread_mutex_init( &mutex, 0 );

@ -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;
}

@ -65,7 +65,7 @@ bool TimerThread::removeTimerUser( TimerUser* timerUser )
bool found( false );
for ( it = m_users.begin(); it != m_users.end(); ) {
if ( (it->second.user) == timerUser ) {
if ( it->second.user == timerUser ) {
tmp = it++;
m_users.erase( tmp );
m_condVar.signal();

Loading…
Cancel
Save