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 void timer_wait(const struct timer *);
31 /* Causes 'timer' to expire when 'duration' milliseconds have passed.
33 * May be used to initialize 'timer'. */
35 timer_set_duration(struct timer *timer, long long int duration)
37 timer->t = time_msec() + duration;
40 /* Causes 'timer' never to expire.
42 * May be used to initialize 'timer'. */
44 timer_set_infinite(struct timer *timer)
49 /* Causes 'timer' to expire immediately.
51 * May be used to initialize 'timer'. */
53 timer_set_expired(struct timer *timer)
58 /* True if 'timer' had (or will have) expired at 'time'. */
60 timer_expired_at(const struct timer *timer, long long int time)
62 return time >= timer->t;
65 /* True if 'timer' has expired. */
67 timer_expired(const struct timer *timer)
69 return timer_expired_at(timer, time_msec());
72 /* Returns ture if 'timer' will never expire. */
74 timer_is_infinite(const struct timer *timer)
76 return timer->t == LLONG_MAX;