(bg & args)
Runs the body in a background thread, and creates a var for the eventual result. The var will have the optionally supplied name or else will be named bg<N>. Logs to out when the background task starts and finishes.
When the body finishes, the var will contain either the result, or any exception that is thrown.
E.g.,
(bg foo (slurp file)) ;; => #'foo (bg (slurp file)) ;; => #'bg0
The var also contains some useful metadata:
:form - the code of the bg call :state - one of #{:running :done :error} :future - a future-like object that can be derefenced, will block, and will throw an exception when appropriate :thread - the thread object running the code
Runs the body in a background thread, and creates a var for the eventual result. The var will have the optionally supplied name or else will be named bg<N>. Logs to *out* when the background task starts and finishes. When the body finishes, the var will contain either the result, or any exception that is thrown. E.g., (bg foo (slurp file)) ;; => #'foo (bg (slurp file)) ;; => #'bg0 The var also contains some useful metadata: :form - the code of the bg call :state - one of #{:running :done :error} :future - a future-like object that can be derefenced, will block, and will throw an exception when appropriate :thread - the thread object running the code
(bg-deref bg-name)
Deref's the given bg object's future. Blocks and returns the value, or throws an exception if the bg threw an exception.
Deref's the given bg object's future. Blocks and returns the value, or throws an exception if the bg threw an exception.
(bg-search key-fn seq)
Given a key-fn and a lazy seq, runs a bg process that updates the given var in the background with the best elements of seq (according to key-fn) seen so far.
Given a key-fn and a lazy seq, runs a bg process that updates the given var in the background with the best elements of seq (according to key-fn) seen so far.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close