0001    //
0002    //  IgnoringFuture.swift
0003    //  Deferred
0004    //
0005    //  Created by Zachary Waldowski on 9/3/15.
0006    //  Copyright © 2014-2015 Big Nerd Ranch. Licensed under MIT.
0007    //
0008    
0009    import Dispatch
0010    
0011    /// A wrapped future that discards the result of the future. The wrapped
0012    /// future is determined when the underlying future is determined, but it
0013    /// is always determined with the empty tuple. In this way, it models the
0014    /// empty "completion" of some event.
0015    ///
0016    /// This is semantically identical to the following:
0017    ///
0018    ///     myFuture.map { _ in }
0019    ///
0020    /// But may behave more efficiently.
0021    public struct IgnoringFuture<Base
IgnoringFuture.swift:22
    private let base: Base
IgnoringFuture.swift:25
    public init(_ base: Base) {
: FutureType>: FutureType { 0022 private let base
IgnoringFuture.swift:26
        self.base = base
IgnoringFuture.swift:36
        return base.upon(queue) { _ in body() }
IgnoringFuture.swift:46
        return base.wait(time).map { _ in }
: Base 0023 0024 /// Creates a future that ignores the result of `base`. 0025 public init(_ base: Base) { 0026 self.base = base 0027 } 0028 0029 /// Call some function once the event completes. 0030 /// 0031 /// If the event is already completed, the function will be submitted to the 0032 /// queue immediately. An `upon` call is always execute asynchronously. 0033 /// 0034 /// - parameter queue: A dispatch queue for executing the given function on. 0035 public func upon(queue: dispatch_queue_t, body: () -> Void) { 0036 return base.upon(queue) { _ in body() } 0037 } 0038 0039 /// Waits synchronously for the event to complete. 0040 /// 0041 /// If the event is already completed, the call returns immediately. 0042 /// 0043 /// - parameter time: A length of time to wait for event to complete. 0044 /// - returns: Nothing, if filled within the timeout, or `nil`. 0045 public func wait(time: Timeout) -> ()? { 0046 return base.wait(time).map { _ in } 0047 } 0048 } 0049