By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,128 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,128 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 ;
};
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Alfonso Morra wrote:
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:" TIMER_CB_FUNC m_cbfunc ;
void restart( void );
unsigned int m_interval ;
time_t m_stime ;
};


Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.