blob: 057d14ea08ebcc7277d5ebbf13c0c1f3f94ba6b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef alarm_h
#define alarm_h
//////////////////////////////////////////////////////////////////////////////
//
// This is an asynchronous timer function that is driven by the alarm()
// system call. I attempt to implement here a half-baked multiple timer
// feature.
//
// Note - you can't really do a lot in a signal handler, stick to setting
// global flags, and making system calls ( **NOT** standard library calls).
//
//////////////////////////////////////////////////////////////////////////////
#include "config.h"
class Alarm;
class Alarm {
static Alarm *first, *last;
Alarm *next, *prev; // List sorted by expiration interval.
unsigned set_interval; // For how many seconds we're set.
void Unlink();
static void cancel_sig(unsigned);
static void set_sig();
static void alarm_func(int);
static unsigned sig_left();
public:
Alarm() : next(0), prev(0), set_interval(0) {}
virtual ~Alarm();
virtual void handler()=0;
void Set(unsigned);
void Cancel();
} ;
#endif
|