 (defmulti ^:no-doc promise* class)
 
 (defmethod promise* clojure.lang.IFn
-  [func]
+  [factory]
   (let [futura (CompletableFuture.)
-        promise (Promise. futura)
-        callback #(deliver promise %)]
+        promise (Promise. futura)]
     (try
-      (func callback)
+      (factory #(deliver promise %))
       (catch Throwable e
         (.completeExceptionally futura e)))
     promise))

  or any callable is provided, that function will be executed with
  one argument as callback for mark the promise resolved or rejected.

      (promise (fn [complete]
                 (future
                   (Thread/sleep 200)
                   (complete 1))))

  The body of that function can be asynchronous and the promise can
  be freely resolved in other thread."
  ([] (promise* nil))
  ([v] (promise* v)))


(defn promise?
  "Returns true if `p` is a promise


(alter-meta! #'->Promise assoc :private true)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
