(defn wait-until
[pred & {:keys [interval-ms]
:or {interval-ms 5000}}]
(while (not (pred))
(Thread/sleep interval-ms)))
(defn- wait-while
[pred & {:keys [interval-ms]
:or {interval-ms 5000}}]
(while (pred)
(Thread/sleep interval-ms)))
;;; usage
(def a (atom false))
(future
(wait-until #(do @a) :interval-ms 1000)
(println "done!"))
(reset! a true)