TAS
TCP Acceleration as an OS Service
utils_timeout.h
1 /*
2  * Copyright 2019 University of Washington, Max Planck Institute for
3  * Software Systems, and The University of Texas at Austin
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef UTILS_TIMEOUT_H_
26 #define UTILS_TIMEOUT_H_
27 
28 #include <stdint.h>
29 
37 struct timeout {
43  uint32_t timeout_type;
44 
46  struct timeout *next;
48  struct timeout *prev;
49 };
50 
51 
59  struct timeout *due_first;
61  struct timeout *due_last;
64  void (*handler)(struct timeout *, uint8_t, void *);
67 };
68 
74 int util_timeout_init(struct timeout_manager *mgr,
75  void (*handler)(struct timeout *, uint8_t, void *), void *handler_opaque);
76 
80 uint32_t util_timeout_time_us(void);
81 
85 void util_timeout_poll(struct timeout_manager *mgr);
86 
90 void util_timeout_poll_ts(struct timeout_manager *mgr, uint32_t cur_ts);
91 
92 uint32_t util_timeout_next(struct timeout_manager *mgr, uint32_t cur_ts);
93 
101 void util_timeout_arm(struct timeout_manager *mgr, struct timeout *to,
102  uint32_t us, uint8_t type);
103 
107 void util_timeout_arm_ts(struct timeout_manager *mgr, struct timeout *to,
108  uint32_t us, uint8_t type, uint32_t cur_ts);
109 
115 void util_timeout_disarm(struct timeout_manager *mgr, struct timeout *to);
116 
119 #endif // ndef UTILS_TIMEOUT_H_
struct timeout * timeouts_first
Definition: utils_timeout.h:55
uint32_t timeout_type
Time and type. Type is stored in the 4 most significant bits, and the time in the 28 least significan...
Definition: utils_timeout.h:43
uint32_t util_timeout_time_us(void)
Definition: timeout.c:72
struct timeout * timeouts_last
Definition: utils_timeout.h:57
struct timeout * due_last
Definition: utils_timeout.h:61
struct timeout * due_first
Definition: utils_timeout.h:59
int util_timeout_init(struct timeout_manager *mgr, void(*handler)(struct timeout *, uint8_t, void *), void *handler_opaque)
Definition: timeout.c:62
void util_timeout_poll(struct timeout_manager *mgr)
Definition: timeout.c:79
struct timeout * next
Definition: utils_timeout.h:46
void util_timeout_disarm(struct timeout_manager *mgr, struct timeout *to)
Definition: timeout.c:155
void util_timeout_poll_ts(struct timeout_manager *mgr, uint32_t cur_ts)
Definition: timeout.c:84
void util_timeout_arm_ts(struct timeout_manager *mgr, struct timeout *to, uint32_t us, uint8_t type, uint32_t cur_ts)
Definition: timeout.c:116
void * handler_opaque
Definition: utils_timeout.h:66
void util_timeout_arm(struct timeout_manager *mgr, struct timeout *to, uint32_t us, uint8_t type)
Definition: timeout.c:110
struct timeout * prev
Definition: utils_timeout.h:48