2 * Copyright (c) 2011 Nicira Networks.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
28 long long int timer_msecs_until_expired(const struct timer *);
29 long long int timer_enabled_at(const struct timer *, long long int duration);
30 void timer_wait(const struct timer *);
32 /* Causes 'timer' to expire when 'duration' milliseconds have passed.
34 * May be used to initialize 'timer'. */
36 timer_set_duration(struct timer *timer, long long int duration)
38 timer->t = time_msec() + duration;
41 /* Causes 'timer' never to expire.
43 * May be used to initialize 'timer'. */
45 timer_set_infinite(struct timer *timer)
50 /* Causes 'timer' to expire immediately.
52 * May be used to initialize 'timer'. */
54 timer_set_expired(struct timer *timer)
59 /* True if 'timer' had (or will have) expired at 'time'. */
61 timer_expired_at(const struct timer *timer, long long int time)
63 return time >= timer->t;
66 /* True if 'timer' has expired. */
68 timer_expired(const struct timer *timer)
70 return timer_expired_at(timer, time_msec());
73 /* Returns ture if 'timer' will never expire. */
75 timer_is_infinite(const struct timer *timer)
77 return timer->t == LLONG_MAX;