/src/openvswitch/lib/timer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2011, 2013 Nicira, Inc. |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at: |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #ifndef TIMER_H |
18 | | #define TIMER_H 1 |
19 | | |
20 | | #include <stdbool.h> |
21 | | |
22 | | #include "timeval.h" |
23 | | #include "util.h" |
24 | | |
25 | | struct timer { |
26 | | long long int t; |
27 | | }; |
28 | | |
29 | | long long int timer_msecs_until_expired(const struct timer *); |
30 | | void timer_wait_at(const struct timer *, const char *where); |
31 | 0 | #define timer_wait(timer) timer_wait_at(timer, OVS_SOURCE_LOCATOR) |
32 | | |
33 | | /* Causes 'timer' to expire when 'duration' milliseconds have passed. |
34 | | * |
35 | | * May be used to initialize 'timer'. */ |
36 | | static inline void |
37 | | timer_set_duration(struct timer *timer, long long int duration) |
38 | 0 | { |
39 | 0 | timer->t = time_msec() + duration; |
40 | 0 | } Unexecuted instantiation: netdev-linux.c:timer_set_duration Unexecuted instantiation: timer.c:timer_set_duration |
41 | | |
42 | | /* Causes 'timer' never to expire. |
43 | | * |
44 | | * May be used to initialize 'timer'. */ |
45 | | static inline void |
46 | | timer_set_infinite(struct timer *timer) |
47 | 0 | { |
48 | 0 | timer->t = LLONG_MAX; |
49 | 0 | } Unexecuted instantiation: netdev-linux.c:timer_set_infinite Unexecuted instantiation: timer.c:timer_set_infinite |
50 | | |
51 | | /* Causes 'timer' to expire immediately. |
52 | | * |
53 | | * May be used to initialize 'timer'. */ |
54 | | static inline void |
55 | | timer_set_expired(struct timer *timer) |
56 | 0 | { |
57 | 0 | timer->t = LLONG_MIN; |
58 | 0 | } Unexecuted instantiation: netdev-linux.c:timer_set_expired Unexecuted instantiation: timer.c:timer_set_expired |
59 | | |
60 | | /* True if 'timer' has expired. */ |
61 | | static inline bool |
62 | | timer_expired(const struct timer *timer) |
63 | 0 | { |
64 | 0 | return time_msec() >= timer->t; |
65 | 0 | } Unexecuted instantiation: netdev-linux.c:timer_expired Unexecuted instantiation: timer.c:timer_expired |
66 | | |
67 | | /* Returns ture if 'timer' will never expire. */ |
68 | | static inline bool |
69 | | timer_is_infinite(const struct timer *timer) |
70 | 0 | { |
71 | 0 | return timer->t == LLONG_MAX; |
72 | 0 | } Unexecuted instantiation: netdev-linux.c:timer_is_infinite Unexecuted instantiation: timer.c:timer_is_infinite |
73 | | |
74 | | #endif /* timer.h */ |