1 /* xlp_timeout.h - data structures for registering callbacks for timeouts
2 
3    Copyright 2001 Carl Worth
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  */
15 
16 #ifndef XLP_TIMEOUT_H
17 #define XLP_TIMEOUT_H
18 
19 #include <sys/time.h>
20 #include <pthread.h>
21 
22 typedef void (*xlp_to_fun_t)(struct timeval start_tv, void *data);
23 
24 struct xlp_timeout
25 {
26     pthread_mutex_t *mutex;
27     struct timeval start_tv;
28     unsigned long delay_ms;
29     xlp_to_fun_t to_fun;
30     void *data;
31     struct xlp_timeout *next;
32 };
33 typedef struct xlp_timeout xlp_timeout_t;
34 
35 int xlp_timeout_init(struct xlp_timeout *to, long delay_ms,
36 		     pthread_mutex_t *mutex,
37 		     xlp_to_fun_t to_fun, void *data);
38 void xlp_timeout_deinit(struct xlp_timeout *to);
39 
40 #endif
41