2 * Layer Two Tunnelling Protocol Daemon
3 * Copyright (C) 1998 Adtran, Inc.
4 * Copyright (C) 2002 Jeff McAdams
8 * This software is distributed under the terms
9 * of the GPL, which you should have received
10 * along with this source.
12 * Scheduler structures and functions
21 * The idea is to provide a general scheduler which can schedule
22 * events to be run periodically
27 struct timeval tv
; /* Scheduled time to execute */
28 void (*func
) (void *); /* Function to execute */
29 void *data
; /* Data to be passed to func */
30 struct schedule_entry
*next
; /* Next entry in queue */
33 extern struct schedule_entry
*events
;
35 /* Schedule func to be executed with argument data sometime
38 struct schedule_entry
*schedule (struct timeval tv
, void (*func
) (void *),
41 /* Like schedule() but tv represents an absolute time in the future */
43 struct schedule_entry
*aschedule (struct timeval tv
, void (*func
) (void *),
46 /* Remove a scheduled event from the queue */
48 void deschedule (struct schedule_entry
*);
50 /* Initialization function */
51 void init_scheduler (void);
53 /* Scheduled event processor */
54 struct timeval
*process_schedule(struct timeval
*);
56 /* Compare two timeval functions and see if a <= b */
58 #define TVLESS(a,b) ((a).tv_sec == (b).tv_sec ? \
59 ((a).tv_usec < (b).tv_usec) : \
60 ((a).tv_sec < (b).tv_sec))
61 #define TVLESSEQ(a,b) ((a).tv_sec == (b).tv_sec ? \
62 ((a).tv_usec <= (b).tv_usec) : \
63 ((a).tv_sec <= (b).tv_sec))
64 #define TVGT(a,b) ((a).tv_sec == (b).tv_sec ? \
65 ((a).tv_usec > (b).tv_usec) : \
66 ((a).tv_sec > (b).tv_sec))