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.
29 long long int timer_msecs_until_expired(const struct timer *);
30 void timer_wait(const struct timer *, const char *where);
31 #define timer_wait(timer) timer_wait(timer, SOURCE_LOCATOR)
33 /* Causes 'timer' to expire when 'duration' milliseconds have passed.
35 * May be used to initialize 'timer'. */
37 timer_set_duration(struct timer *timer, long long int duration)
39 timer->t = time_msec() + duration;
42 /* Causes 'timer' never to expire.
44 * May be used to initialize 'timer'. */
46 timer_set_infinite(struct timer *timer)
51 /* Causes 'timer' to expire immediately.
53 * May be used to initialize 'timer'. */
55 timer_set_expired(struct timer *timer)
60 /* True if 'timer' has expired. */
62 timer_expired(const struct timer *timer)
64 return time_msec() >= timer->t;
67 /* Returns ture if 'timer' will never expire. */
69 timer_is_infinite(const struct timer *timer)
71 return timer->t == LLONG_MAX;