   [x]
   (ConstantReadPort. (channels/box x)))
 
-(defn cast-as-readport
-  [x]
-  (if (readport? x) x (constant x)))
+(defrecord AsyncFuture [state-atom]
+  impl/ReadPort
+  (take! [_ handler]
+    (-> state-atom
+        (swap! (fn [state]
+                 (if (nil? (:boxed-value state))
+                   (update-in state [:handlers] conj handler)
+                   state)))
+        :boxed-value)))
 
 (defn- async-future-state-atom
   [f]

    (f resolve!)
    state-atom))

(defrecord AsyncFuture [state-atom]
  impl/ReadPort
  (take! [_ handler]
    (-> state-atom
        (swap! (fn [state]
                 (if (nil? (:boxed-value state))
                   (update-in state [:handlers] conj handler)
                   state)))
        :boxed-value)))

(defn async-future*
  [f]
  (AsyncFuture. (async-future-state-atom f)))

(defn async-future<
  [ch]
  (async-future* (partial async/take! ch)))

(defn readport?
  [x]
  (satisfies? impl/ReadPort x))

(defn cast-as-readport
  [x]
  (if (readport? x) x (constant x)))

(defn then<
  [f ch]
