+
+ /// Creates a `DispatchTime` relative to the system clock that
+ /// ticks since boot.
+ ///
+ /// - Parameters:
+ /// - uptimeNanoseconds: The number of nanoseconds since boot, excluding
+ /// time the system spent asleep
+ /// - Returns: A new `DispatchTime`
+ /// - Discussion: This clock is the same as the value returned by
+ /// `mach_absolute_time` when converted into nanoseconds.
+ /// On some platforms, the nanosecond value is rounded up to a
+ /// multiple of the Mach timebase, using the conversion factors
+ /// returned by `mach_timebase_info()`. The nanosecond equivalent
+ /// of the rounded result can be obtained by reading the
+ /// `uptimeNanoseconds` property.
+ /// Note that `DispatchTime(uptimeNanoseconds: 0)` is
+ /// equivalent to `DispatchTime.now()`, that is, its value
+ /// represents the number of nanoseconds since boot (excluding
+ /// system sleep time), not zero nanoseconds since boot.
+ public init(uptimeNanoseconds: UInt64) {
+ var rawValue = uptimeNanoseconds
+#if HAVE_MACH
+ if (DispatchTime.timebaseInfo.numer != DispatchTime.timebaseInfo.denom) {
+ rawValue = (rawValue * UInt64(DispatchTime.timebaseInfo.denom)
+ + UInt64(DispatchTime.timebaseInfo.numer - 1)) / UInt64(DispatchTime.timebaseInfo.numer)
+ }
+#endif
+ self.rawValue = dispatch_time_t(rawValue)
+ }
+
+ public var uptimeNanoseconds: UInt64 {
+ var result = self.rawValue
+#if HAVE_MACH
+ if (DispatchTime.timebaseInfo.numer != DispatchTime.timebaseInfo.denom) {
+ result = result * UInt64(DispatchTime.timebaseInfo.numer) / UInt64(DispatchTime.timebaseInfo.denom)
+ }
+#endif
+ return result
+ }
+}
+
+public func <(a: DispatchTime, b: DispatchTime) -> Bool {
+ if a.rawValue == ~0 || b.rawValue == ~0 { return false }
+ return a.rawValue < b.rawValue