         return d
     }
 
+    /**
+    Transforms the deferred value once it becomes determined.
+
+    :param: queue A dispatch queue for executing the transform on.
+    :param: transform A function to create something using the deferred value.
+    :returns: A new deferred value that is determined once the recieving
+    deferred is determined.
+    **/
     public func map<NewValue>(upon queue: dispatch_queue_t = DeferredDefaultQueue, transform: Value -> NewValue) -> Deferred<NewValue> {
         let d = Deferred<NewValue>()
         upon(queue) {

            dispatch_async(queue) { block(filledValue) }
        }
    }

    public func peek() -> Value? {
        return protected.withReadLock { $0.protected }
    }

    public func upon(_ queue: dispatch_queue_t = DeferredDefaultQueue, function: Value -> ()) {
        let maybeValue: Value? = protected.withWriteLock{ data in
            if data.protected == nil {

    return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
}

/// A deferred is a value that may become determined (or "filled") at some point
/// in the future. Once a deferred value is determined, it cannot change.
public struct Deferred<Value> {
    typealias UponBlock = (dispatch_queue_t, Value -> ())
    private typealias Protected = (protected: Value?, uponBlocks: [UponBlock])
    
    private var protected: LockProtected<Protected>
    
    private init(_ value: Value?) {
        protected = LockProtected(item: (value, []))
    }
    
    /// Initialize an unfilled Deferred.
    public init() {
        self.init(nil)
    }
    
    /// Initialize a filled Deferred with the given value.
    public init(value: Value) {
        self.init(value)
    }
    
    /// Check whether or not the receiver is filled.
    public var isFilled: Bool {
        return protected.withReadLock { $0.protected != nil }
    }
    
    /// Determines the deferred value with a given result.
    ///
    /// Filling a deferred value should usually be attempted only once, and by
    /// default filling will trap upon improper usage.
    ///
    /// * In playgrounds and unoptimized builds (the default for a "Debug"
    ///   configuration), program execution will be stopped at the caller in
    ///   a debuggable state.
    /// * In -O builds (the default for a "Release" configuration), program
    ///   execution will stop.
    /// * In -Ounchecked builds, the programming error is assumed to not exist.
    ///
    /// If your deferred requires multiple potential fillers to race, you may
    /// disable the precondition.
    ///
    /// :param: value The resolved value of the deferred.
    /// :param: assertIfFilled If `false`, race checking is disabled.
    public func fill(value: Value, assertIfFilled: Bool = true, file: StaticString = __FILE__, line: UWord = __LINE__) {
        let (filledValue, blocks) = protected.withWriteLock { data -> (Value, [UponBlock]) in
            if assertIfFilled {
