0001    //
0002    //  DispatchSemaphore.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 struct DispatchSemaphore: DispatchObject, DispatchWaitable {
0011    
0012        @available(*, unavailable, renamed="rawValue")
0013        public var semaphore: dispatch_semaphore_t {
0014            return rawValue
0015        }
0016    
0017        @available(*, unavailable, renamed="DispatchSemaphore(rawValue:)")
0018        public init(raw semaphore: dispatch_semaphore_t) {
0019            self.rawValue = semaphore
0020        }
0021    
0022        public let rawValue
DispatchSemaphore.swift:25
        self.rawValue = rawValue
DispatchSemaphore.swift:35
        self.rawValue = rawValue
DispatchSemaphore.swift:45
        return dispatch_semaphore_wait(rawValue, timeout.rawValue)
DispatchSemaphore.swift:49
        return dispatch_semaphore_signal(rawValue)
: dispatch_semaphore_t 0023 0024 public init(rawValue: dispatch_semaphore_t) { 0025 self.rawValue = rawValue 0026 } 0027 0028 public init!(_ value: Int) { 0029 assert(0 <= value) 0030 0031 guard let rawValue = dispatch_semaphore_create(value) else { 0032 return nil 0033 } 0034 0035 self.rawValue = rawValue 0036 } 0037 0038 0039 public func wait() -> Int { 0040 // default argument is not permitted in protocol method in #swift 0041 return wait(.Forever) 0042 } 0043 0044 public func wait
DispatchSemaphore.swift:41
        return wait(.Forever)
(timeout: DispatchTime) -> Int { 0045 return dispatch_semaphore_wait(rawValue, timeout.rawValue) 0046 } 0047 0048 public func signal() -> Int { 0049 return dispatch_semaphore_signal(rawValue) 0050 } 0051 0052 } 0053