]>
git.saurik.com Git - apple/libdispatch.git/blob - src/time.h
2 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __DISPATCH_TIME__
22 #define __DISPATCH_TIME__
24 #ifndef __DISPATCH_INDIRECT__
25 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
26 #include <dispatch/base.h> // for HeaderDoc
45 #define NSEC_PER_SEC 1000000000ull
46 #define USEC_PER_SEC 1000000ull
47 #define NSEC_PER_USEC 1000ull
50 * @typedef dispatch_time_t
53 * An somewhat abstract representation of time; where zero means "now" and
54 * DISPATCH_TIME_FOREVER means "infinity" and every value in between is an
57 typedef uint64_t dispatch_time_t
;
59 #define DISPATCH_TIME_NOW 0
60 #define DISPATCH_TIME_FOREVER (~0ull)
63 * @function dispatch_time
66 * Create dispatch_time_t relative to the default clock or modify an existing
70 * On Mac OS X the default clock is based on mach_absolute_time().
73 * An optional dispatch_time_t to add nanoseconds to. If zero is passed, then
74 * dispatch_time() will use the result of mach_absolute_time().
80 * A new dispatch_time_t.
82 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
85 dispatch_time(dispatch_time_t when
, int64_t delta
);
88 * @function dispatch_walltime
91 * Create a dispatch_time_t using the wall clock.
94 * On Mac OS X the wall clock is based on gettimeofday(3).
97 * A struct timespect to add time to. If NULL is passed, then
98 * dispatch_walltime() will use the result of gettimeofday(3).
101 * Nanoseconds to add.
104 * A new dispatch_time_t.
106 __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
)
109 dispatch_walltime(const struct timespec
*when
, int64_t delta
);