help with "rolling my own" Timer class
- From: Alfonso Morra <sweet-science@xxxxxxxxxxxx>
- Date: Mon, 18 Jul 2005 23:20:18 +0000 (UTC)
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 requiredprivate: 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
.
- Follow-Ups:
- Re: help with "rolling my own" Timer class
- From: William DePalo [MVP VC++]
- Re: help with "rolling my own" Timer class
- Prev by Date: Support link missing for C++.NET 2003 ?
- Next by Date: Re: Support link missing for C++.NET 2003 ?
- Previous by thread: Support link missing for C++.NET 2003 ?
- Next by thread: Re: help with "rolling my own" Timer class
- Index(es):
Relevant Pages
|