0001 // 0002 // DispatchTime.swift 0003 // DispatchKit <https://github.com/anpol/DispatchKit> 0004 // 0005 // Copyright (c) 2014 Andrei Polushin. All rights reserved. 0006 // 0007 0008 import Foundation 0009 0010 public enum DispatchTime{ 0011 0012 case Forever
DispatchGroup.swift:51 public func wait(timeout: DispatchTime) -> Int {DispatchObject.swift:26 func wait(timeout: DispatchTime) -> IntDispatchQueue.swift:133 public func after(when: DispatchTime, block: dispatch_block_t) {DispatchSemaphore.swift:44 public func wait(timeout: DispatchTime) -> Int {DispatchSource.swift:84 public func setTimer(start: DispatchTime, interval: DispatchTimeDelta, leeway: DispatchTimeDelta) {DispatchTime.swift:71 public func +(time: DispatchTime, delta: DispatchTimeDelta) -> DispatchTime {DispatchTime.swift:71 public func +(time: DispatchTime, delta: DispatchTimeDelta) -> DispatchTime {DispatchTime.swift:86 public func +(delta: DispatchTimeDelta, time: DispatchTime) -> DispatchTime {DispatchTime.swift:86 public func +(delta: DispatchTimeDelta, time: DispatchTime) -> DispatchTime {0013 0014 case Now
DispatchGroup.swift:48 return wait(.Forever)DispatchSemaphore.swift:41 return wait(.Forever)DispatchTime.swift:22 case .Forever:DispatchTime.swift:73 case .Forever:0015 case NowDelta
DispatchTime.swift:24 case .Now:DispatchTime.swift:75 case .Now:(Int64) 0016 0017 case WallClock
DispatchTime.swift:26 case let .NowDelta(nsec):DispatchTime.swift:76 return .NowDelta(delta.toNanoseconds())DispatchTime.swift:77 case let .NowDelta(nsec):DispatchTime.swift:78 return .NowDelta(nsec + delta.toNanoseconds())(UnsafePointer<timespec>) 0018 case WallClockDelta
DispatchTime.swift:28 case let .WallClock(timespec):DispatchTime.swift:79 case let .WallClock(timespec):(UnsafePointer<timespec>, Int64) 0019 0020 public var rawValue
DispatchTime.swift:30 case let .WallClockDelta(timespec, nsec):DispatchTime.swift:80 return .WallClockDelta(timespec, delta.toNanoseconds())DispatchTime.swift:81 case let .WallClockDelta(timespec, nsec):DispatchTime.swift:82 return .WallClockDelta(timespec, nsec + delta.toNanoseconds()): dispatch_time_t { 0021 switch self { 0022 case .Forever: 0023 return DISPATCH_TIME_FOREVER 0024 case .Now: 0025 return DISPATCH_TIME_NOW 0026 case let .NowDelta(nsec): 0027 return dispatch_time(DISPATCH_TIME_NOW, nsec) 0028 case let .WallClock(timespec): 0029 return dispatch_walltime(timespec, 0) 0030 case let .WallClockDelta(timespec, nsec): 0031 return dispatch_walltime(timespec, nsec) 0032 } 0033 } 0034 0035 } 0036 0037 0038 public enum DispatchTimeDelta
DispatchGroup.swift:52 return dispatch_group_wait(rawValue, timeout.rawValue)DispatchQueue.swift:134 dispatch_after(when.rawValue, rawValue, block)DispatchSemaphore.swift:45 return dispatch_semaphore_wait(rawValue, timeout.rawValue)DispatchSource.swift:85 dispatch_source_set_timer(rawValue, start.rawValue, interval.rawValue, leeway.rawValue){ 0039 0040 case Nanoseconds
DispatchSource.swift:84 public func setTimer(start: DispatchTime, interval: DispatchTimeDelta, leeway: DispatchTimeDelta) {DispatchSource.swift:84 public func setTimer(start: DispatchTime, interval: DispatchTimeDelta, leeway: DispatchTimeDelta) {DispatchTime.swift:71 public func +(time: DispatchTime, delta: DispatchTimeDelta) -> DispatchTime {DispatchTime.swift:86 public func +(delta: DispatchTimeDelta, time: DispatchTime) -> DispatchTime {DispatchTime.swift:90 public func +(delta1: DispatchTimeDelta, delta2: DispatchTimeDelta) -> DispatchTimeDelta {DispatchTime.swift:90 public func +(delta1: DispatchTimeDelta, delta2: DispatchTimeDelta) -> DispatchTimeDelta {DispatchTime.swift:90 public func +(delta1: DispatchTimeDelta, delta2: DispatchTimeDelta) -> DispatchTimeDelta {(Int64) 0041 case Microseconds
DispatchTime.swift:52 case let .Nanoseconds(nsec): t = UInt64(nsec)DispatchTime.swift:91 return .Nanoseconds(delta1.toNanoseconds() + delta2.toNanoseconds())(Int64) 0042 case Milliseconds
DispatchTime.swift:53 case let .Microseconds(usec): t = UInt64(usec) * NSEC_PER_USEC(Int64) 0043 case Seconds
DispatchTime.swift:54 case let .Milliseconds(msec): t = UInt64(msec) * NSEC_PER_MSEC(Int64) 0044 case Minutes
DispatchTime.swift:55 case let .Seconds(sec): t = UInt64(sec) * NSEC_PER_SEC(Int) 0045 case Hours
DispatchTime.swift:56 case let .Minutes(mins): t = UInt64(mins * 60) * NSEC_PER_SEC(Int) 0046 case Days
DispatchTime.swift:57 case let .Hours(hrs): t = UInt64(hrs * 3600) * NSEC_PER_SEC(Int) 0047 case Weeks
DispatchTime.swift:58 case let .Days(days): t = UInt64(days * 3600 * 24) * NSEC_PER_SEC(Int) 0048 0049 public var rawValue
DispatchTime.swift:59 case let .Weeks(wks): t = UInt64(wks * 3600 * 24 * 7) * NSEC_PER_SEC: UInt64 { 0050 var t: UInt64 0051 switch self { 0052 case let .Nanoseconds(nsec): t = UInt64(nsec) 0053 case let .Microseconds(usec): t = UInt64(usec) * NSEC_PER_USEC 0054 case let .Milliseconds(msec): t = UInt64(msec) * NSEC_PER_MSEC 0055 case let .Seconds(sec): t = UInt64(sec) * NSEC_PER_SEC 0056 case let .Minutes(mins): t = UInt64(mins * 60) * NSEC_PER_SEC 0057 case let .Hours(hrs): t = UInt64(hrs * 3600) * NSEC_PER_SEC 0058 case let .Days(days): t = UInt64(days * 3600 * 24) * NSEC_PER_SEC 0059 case let .Weeks(wks): t = UInt64(wks * 3600 * 24 * 7) * NSEC_PER_SEC 0060 } 0061 return t 0062 } 0063 0064 public func toNanoseconds
DispatchSource.swift:85 dispatch_source_set_timer(rawValue, start.rawValue, interval.rawValue, leeway.rawValue)DispatchSource.swift:85 dispatch_source_set_timer(rawValue, start.rawValue, interval.rawValue, leeway.rawValue)DispatchTime.swift:65 return Int64(rawValue)() -> Int64 { 0065 return Int64(rawValue) 0066 } 0067 0068 } 0069 0070 0071 public func +(time: DispatchTime, delta: DispatchTimeDelta) -> DispatchTime { 0072 switch time { 0073 case .Forever: 0074 return time 0075 case .Now: 0076 return .NowDelta(delta.toNanoseconds()) 0077 case let .NowDelta(nsec): 0078 return .NowDelta(nsec + delta.toNanoseconds()) 0079 case let .WallClock(timespec): 0080 return .WallClockDelta(timespec, delta.toNanoseconds()) 0081 case let .WallClockDelta(timespec, nsec): 0082 return .WallClockDelta(timespec, nsec + delta.toNanoseconds()) 0083 } 0084 } 0085 0086 public func +(delta: DispatchTimeDelta, time: DispatchTime) -> DispatchTime { 0087 return time + delta 0088 } 0089 0090 public func +(delta1: DispatchTimeDelta, delta2: DispatchTimeDelta) -> DispatchTimeDelta { 0091 return .Nanoseconds(delta1.toNanoseconds() + delta2.toNanoseconds()) 0092 } 0093
DispatchTime.swift:76 return .NowDelta(delta.toNanoseconds())DispatchTime.swift:78 return .NowDelta(nsec + delta.toNanoseconds())DispatchTime.swift:80 return .WallClockDelta(timespec, delta.toNanoseconds())DispatchTime.swift:82 return .WallClockDelta(timespec, nsec + delta.toNanoseconds())DispatchTime.swift:91 return .Nanoseconds(delta1.toNanoseconds() + delta2.toNanoseconds())DispatchTime.swift:91 return .Nanoseconds(delta1.toNanoseconds() + delta2.toNanoseconds())