         private var memoizedResult: Result? // nil when pending
         private var inlinedHandler: ((Result) -> Void)?
         private var handlers: [(Result) -> Void]?
-        private let lock = NSLock()
+        /// The Lock fastest option (https://gist.github.com/steipete/36350a8a60693d440954b95ea6cbbafc)
+        private var lock = os_unfair_lock()
 
         /// Creates a new pending promise.
         public init() {}

                    handlers = handlers ?? []
                    handlers?.append(completion)
                }
                lock.unlock(); return // Still pending, handlers attached
            }
            lock.unlock()

            completion(result)
        }

        /// Returns the result if the future completed.
        var result: Result? {
            lock.lock(); defer { lock.unlock() }
            return memoizedResult
        }

        // MARK: CustomDebugStringConvertible

        public var debugDescription: String {
            lock.lock(); defer { lock.unlock() }
            if let result = self.memoizedResult {
                return "Promise<\(Value.self), \(Error.self)> { .resolved(result: \(result)) }"
            } else {
                let handlerCount = (handlers?.count ?? 0) + (inlinedHandler != nil ? 1 : 0)


        /// 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 {
