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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top