A
Alfonso Morra
Hi,
I am writing a timer class that I want to be able to get to notify me
(via a callback func), when a specified interval has elapsed. I have
most of the timer functionality figured - however, I need to spawn a new
thread to carry out the "time watch" - and I need to do this in a cross
platform (Well Linux/Windows) way ...
Any help will be much appreciated. The code (snippet) follows below:
#include <ctime>
typedef void (*TIMER_CB_FUNC)( void ) ;
class Timer {
public:
inline Timer():m_cbfunc(0),m_interval(0),m_stime(0){} ;
Timer( TIMER_CB_FUNC, unsigned short) ;
Timer( const Timer&) ;
Timer& operator= (const Timer& ) ;
virtual ~Timer() ; //not really required
private:
TIMER_CB_FUNC m_cbfunc ;
unsigned short m_interval ;
time_t m_stime ;
/* private functions */
void reset( void );
};
Basically when the Timer class is constructed, it must start a new
thread that waits till the time is up and then notifies me. MTIA
I am writing a timer class that I want to be able to get to notify me
(via a callback func), when a specified interval has elapsed. I have
most of the timer functionality figured - however, I need to spawn a new
thread to carry out the "time watch" - and I need to do this in a cross
platform (Well Linux/Windows) way ...
Any help will be much appreciated. The code (snippet) follows below:
#include <ctime>
typedef void (*TIMER_CB_FUNC)( void ) ;
class Timer {
public:
inline Timer():m_cbfunc(0),m_interval(0),m_stime(0){} ;
Timer( TIMER_CB_FUNC, unsigned short) ;
Timer( const Timer&) ;
Timer& operator= (const Timer& ) ;
virtual ~Timer() ; //not really required
private:
TIMER_CB_FUNC m_cbfunc ;
unsigned short m_interval ;
time_t m_stime ;
/* private functions */
void reset( void );
};
Basically when the Timer class is constructed, it must start a new
thread that waits till the time is up and then notifies me. MTIA