For very simple cases: If you do not want to block and do not care about the result, just add a callback to the future definition.
(future (a-taking-time-computation) (the-callback))
If you care about the results, use comp with a callback
(future (the-callback (a-taking-time-computation)))
or
(future (-> input a-taking-time-computation callback))
Semantically speaking, the equivalent java code would be:
final MyCallBack callbackObj = new MyCallBack(); new Thread() { public void run() { a-taking-time-computation(); callbackObj.call(); } }.start()
In difficult cases, you can see:
https://github.com/ztellman/manifold
https://github.com/clojure/core.async
source share