       self.state = state
     }
 
-    internal func resolve(with result: Result<Value, Error>) -> (Result<Value, Error>, [ResultHandler]) {
+    internal func resolve(with result: Result<Value, Error>) -> PromiseSourceAction {
       lock.lock(); defer { lock.unlock() }
-      
+
       let handlersToExecute: [ResultHandler]
-      
+
       switch state {
       case .unresolved:
         state = result.state

      default:
        handlersToExecute = []
      }
      
      return (result, handlersToExecute)
    }

    internal func addHandler(_ handler: @escaping ResultHandler) -> (Result<Value, Error>, [ResultHandler])? {
      lock.lock(); defer { lock.unlock() }

      switch state {


      case .resolved(let value):
        // Value is already available, call handler immediately
        return PromiseSourceAction(result: .value(value), handlers: [handler])

      case .rejected(let error):
        // Error is already available, call handler immediately
        return PromiseSourceAction(result: .error(error), handlers: [handler])
      }
    }
  }
}

internal func callHandlers<T>(_ handlers: [(T) -> Void], with value: T, dispatchKey: DispatchSpecificKey<Void>, dispatchMethod: DispatchMethod) {

  for handler in handlers {
    switch dispatchMethod {
