0001    //
0002    //  DispatchObjectContext.swift
0003    //  DispatchKit <https://github.com/anpol/DispatchKit>
0004    //
0005    //  Copyright (c) 2015 Andrei Polushin. All rights reserved.
0006    //
0007    
0008    import Foundation
0009    
0010    func dk_takeUnretained
DispatchObjectContext.swift:31
        return dk_takeUnretained(context)
DispatchQueueSpecific.swift:13
        return dk_takeUnretained(specific)
DispatchQueueSpecific.swift:24
        return dk_takeUnretained(specific)
<T: AnyObject>(ptr: UnsafeMutablePointer<Void>) -> T? { 0011 if ptr != nil { 0012 return Unmanaged<T>.fromOpaque(COpaquePointer(ptr)).takeUnretainedValue() 0013 } 0014 return nil 0015 } 0016 0017 func dk_passRetained
DispatchObjectContext.swift:35
        dispatch_set_context(rawValue, dk_passRetained(context))
DispatchQueueSpecific.swift:17
        dispatch_queue_set_specific(rawValue, key, dk_passRetained(specific), dk_release)
<T: AnyObject>(obj: T?) -> UnsafeMutablePointer<Void> { 0018 if let obj = obj { 0019 return UnsafeMutablePointer(Unmanaged.passRetained(obj).toOpaque()) 0020 } 0021 return nil 0022 } 0023 0024 func dk_release
DispatchObjectContext.swift:36
        dispatch_set_finalizer_f(rawValue, dk_release)
DispatchQueueSpecific.swift:17
        dispatch_queue_set_specific(rawValue, key, dk_passRetained(specific), dk_release)
(ptr: UnsafeMutablePointer<Void>) { 0025 Unmanaged<AnyObject>.fromOpaque(COpaquePointer(ptr)).release() 0026 } 0027 0028 public extension DispatchObject { 0029 func getContext<T: AnyObject>() -> T? { 0030 let context = dispatch_get_context(rawValue) 0031 return dk_takeUnretained(context) 0032 } 0033 0034 func setContext<T: AnyObject>(context: T?) { 0035 dispatch_set_context(rawValue, dk_passRetained(context)) 0036 dispatch_set_finalizer_f(rawValue, dk_release) 0037 } 0038 } 0039