         }
     }
     
-    fileprivate func reserve(_ handler: @escaping (T) -> ()) {
+    private func reserve(_ handler: @escaping (T) -> ()) {
         lock.lock()
         if let value = self.value {
             handler(value)

        executor(resolve)
    }
    
    fileprivate func resolve(_ promise: Promise<T>) {
        promise.reserve {
            self.lock.lock()
            if self.value == nil {

import Foundation

public class Promise<T> {
    private let lock = NSRecursiveLock()
    
    fileprivate var value: T?
    private var handlers: [(T) -> ()] = []
    
    public init(_ value: T) {
        self.value = value
