mirror of https://github.com/tstack/lnav
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
809 B
C++
34 lines
809 B
C++
10 years ago
|
#ifndef timer_hh
|
||
|
#define timer_hh
|
||
|
|
||
|
#include <errno.h>
|
||
|
#include <signal.h>
|
||
|
#include <exception>
|
||
|
#include <sys/time.h>
|
||
|
#include <sys/types.h>
|
||
|
|
||
|
// Linux and BSD seem to name the function pointer to signal handler differently.
|
||
|
// Linux names it 'sighandler_t' and BSD names it 'sig_t'. Instead of depending
|
||
|
// on configure scripts to find out the type name, typedef it right here.
|
||
|
typedef void (*sighandler_t_)(int);
|
||
|
|
||
|
namespace timer{
|
||
|
class error : public std::exception {
|
||
|
public:
|
||
|
error(int err);
|
||
|
int e_err;
|
||
|
};
|
||
|
|
||
|
class interrupt_timer {
|
||
|
public:
|
||
|
interrupt_timer(struct timeval, sighandler_t_);
|
||
|
int arm_timer();
|
||
|
~interrupt_timer();
|
||
|
private:
|
||
|
struct itimerval new_val, old_val;
|
||
|
sighandler_t_ new_handler, old_handler;
|
||
|
bool armed;
|
||
|
};
|
||
|
}
|
||
|
#endif
|