Initial commit of files
This commit is contained in:
80
include/libnet++/Timer.h
Normal file
80
include/libnet++/Timer.h
Normal file
@ -0,0 +1,80 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Timer__
|
||||
#define __Timer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Timer {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
struct timespec m_timespec;
|
||||
bool m_running;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Timer();
|
||||
|
||||
// destructor
|
||||
virtual ~Timer();
|
||||
|
||||
// public methods
|
||||
|
||||
// virtual functions
|
||||
virtual int Restart(void);
|
||||
virtual int Start( unsigned long usec );
|
||||
virtual void Stop(void);
|
||||
virtual unsigned long Remaining(void);
|
||||
virtual int Wait(void);
|
||||
virtual int Sync(void); // Wait()+Restart()
|
||||
|
||||
// exceptions
|
||||
class TimerException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
static void Sleep( unsigned int sec ) { sleep(sec); };
|
||||
static void MilliSleep( unsigned long msec ) { msleep(msec); };
|
||||
static void MicroSleep( unsigned long usec ) { usleep(usec); };
|
||||
static void NanoSleep( unsigned long nsleep );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user