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