Help on writing a timer class (cross platform thread spawing)

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 mucho appreciated. The code (snippet) follows below:


#include <time.h>

typedef void (*TIMER_CB_FUNC)( void ) ;

class Timer {
public:
Timer() ;
virtual ~Timer() ; //not really required
registerCallBack( TIMER_CB_FUNC, unsigned int ) ;

private
TIMER_CB_FUNC m_cbfunc ;
void restart( void );
unsigned int m_interval ;
time_t m_stime ;
};
 
A

Alfonso Morra

Alfonso said:
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 mucho appreciated. The code (snippet) follows below:


#include <time.h>

typedef void (*TIMER_CB_FUNC)( void ) ;

class Timer {
public:
Timer() ;
virtual ~Timer() ; //not really required
registerCallBack( TIMER_CB_FUNC, unsigned int ) ;

private
Typo Alert: this needs to be "private:"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top