 }
 
 // MARK: - Promise
-
 extension Future {
 
     /// A promise to provide a result later.

        private var memoizedResult: Result? // nil when pending
        private var inlinedHandler: ((Result) -> Void)?
        private var handlers: [(Result) -> Void]?
        private let lock = NSLock()

        /// Creates a new pending promise.
        public init() {}


        /// Sends a result to the associated future.
        public func resolve(result: Result) {
            os_unfair_lock_lock(&lock)
            guard self.memoizedResult == nil else {
                os_unfair_lock_unlock(&lock)
                return // Already resolved
            }
            self.memoizedResult = result
            let inlinedHandler = self.inlinedHandler
            let handlers = self.handlers
            self.inlinedHandler = nil
            self.handlers = nil
            os_unfair_lock_unlock(&lock)

            inlinedHandler?(result)
            handlers?.forEach { $0(result) }
        }

        func observe(completion: @escaping (Result) -> Void) {
            os_unfair_lock_lock(&lock)
            guard let result = memoizedResult else {
                if inlinedHandler == nil {
                    inlinedHandler = completion
                } else {
