 
         // slow path - block until filled
         let group = dispatch_group_create()
-        var result: T!
+        var result: Value!
         dispatch_group_enter(group)
         self.upon { result = $0; dispatch_group_leave(group) }
         dispatch_group_wait(group, DISPATCH_TIME_FOREVER)

    }

    // Initialize a filled Deferred with the given value
    public convenience init(value: T) {
        self.init(value: value)
    }

    // Check whether or not the receiver is filled
    public var isFilled: Bool {
        return protected.withReadLock { $0.protectedValue != nil }
    }

    private func _fill(value: T, assertIfFilled: Bool) {
        let (filledValue, blocks) = protected.withWriteLock { data -> (T, [UponBlock]) in
            if assertIfFilled {
                precondition(data.protectedValue == nil, "Cannot fill an already-filled Deferred")
                data.protectedValue = value
            } else if data.protectedValue == nil {
                data.protectedValue = value
            }
            let blocks = data.uponBlocks
            data.uponBlocks.removeAll(keepCapacity: false)
            return (data.protectedValue!, blocks)
        }
        for (queue, block) in blocks {
            dispatch_async(queue) { block(filledValue) }
        }
    }

    public func fill(value: T) {
        _fill(value, assertIfFilled: true)
    }

    public func fillIfUnfilled(value: T) {
        _fill(value, assertIfFilled: false)
    }

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

    public func upon(_ queue: dispatch_queue_t = DeferredDefaultQueue, function: T -> ()) {
        let maybeValue: T? = protected.withWriteLock{ data in
            if data.protectedValue == nil {
                data.uponBlocks.append( (queue, function) )
            }
            return data.protectedValue
        }
        if let value = maybeValue {
            dispatch_async(queue) { function(value) }

}

extension Deferred {
    public var value: Value {
        // fast path - return if already filled
        if let v = peek() {
            return v
