Skip to content
Snippets Groups Projects
Commit c270ee9c authored by Simon Belak's avatar Simon Belak
Browse files

Don't defer done futures

parent 342e6942
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,12 @@
(defn result!
"Blocking version of async/result."
[job-id]
(let [f (-> #'async/running-jobs
deref ; var
deref ; atom
(get job-id))]
(when (and f (not (future-cancelled? f)))
(when-let [f (-> #'async/running-jobs
deref ; var
deref ; atom
(get job-id))]
(when-not (or (future-cancelled? f)
(future-done? f))
@f))
(async/result (ComputationJob job-id)))
......@@ -20,7 +21,8 @@
10000000)
(defmacro while-with-timeout
"Like while except it runs a maximum of `*max-while-runtime*` milliseconds."
"Like `clojure.core/while` except it runs a maximum of `*max-while-runtime*`
milliseconds (assuming running time for one iteration is << `*max-while-runtime*`)."
[test & body]
`(let [start# (System/currentTimeMillis)]
(while (and ~test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment