Xenomai  3.0.8
timerwheel.h
1 /***
2  *
3  * ipv4/tcp/timerwheel.h - timerwheel interface for RTnet
4  *
5  * Copyright (C) 2009 Vladimir Zapolskiy <vladimir.zapolskiy@siemens.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License, version 2, as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21 
22 #ifndef __TIMERWHEEL_H_
23 #define __TIMERWHEEL_H_
24 
25 #include <linux/list.h>
26 #include <rtdm/net.h>
27 
28 #define TIMERWHEEL_TIMER_UNUSED -1
29 
30 typedef void (*timerwheel_timer_handler)(void *);
31 
32 struct timerwheel_timer {
33  struct list_head link;
34  timerwheel_timer_handler handler;
35  void *data;
36  int slot;
37  volatile int refcount; /* only written by wheel task */
38 };
39 
40 static inline void
41 timerwheel_init_timer(struct timerwheel_timer *timer,
42  timerwheel_timer_handler handler, void *data)
43 {
44  timer->slot = TIMERWHEEL_TIMER_UNUSED;
45  timer->handler = handler;
46  timer->data = data;
47  timer->refcount = 0;
48 }
49 
50 /* passed data must remain valid till a timer fireup */
51 int timerwheel_add_timer(struct timerwheel_timer *timer,
52  nanosecs_rel_t expires);
53 
54 int timerwheel_remove_timer(struct timerwheel_timer *timer);
55 
56 void timerwheel_remove_timer_sync(struct timerwheel_timer *timer);
57 
58 int timerwheel_init(nanosecs_rel_t timeout,
59  unsigned int granularity);
60 
61 void timerwheel_cleanup(void);
62 
63 #endif
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:49