(async expr)If expr is a fn or defn form, its body will
run asyncronously. Otherwise, expr will itself
run asyncronously, and return a CompletableFuture.
All async exectution occurs on the ci/*executor* pool,
which is bound to the common ForkJoinPool by default.
If `expr` is a `fn` or `defn` form, its body will run asyncronously. Otherwise, `expr` will itself run asyncronously, and return a `CompletableFuture`. All async exectution occurs on the `ci/*executor*` pool, which is bound to the common ForkJoinPool by default.
(await promise)(await promise timeout-ms timeout-val)Use inside async let bindings.
The let block will return a CompletableFuture.
(async (let [x (async :x) y (await x)] y))
Will wait for the CompletableFuture to complete
before evaluation resumes.
Use inside `async` `let` bindings.
The `let` block will return a `CompletableFuture`.
(async
(let [x (async :x)
y (await x)]
y))
Will wait for the `CompletableFuture` to complete
before evaluation resumes.(complete promise x)Completes the CompletableFuture.
It will contain x.
Completes the `CompletableFuture`. It will contain x.
(promise)(promise [resolve] & body)Used to get values out of callbacks.
ex: ;; some fn that takes a callback (defn fetch [url callback] ...)
;; can be used as (def p (promise [resolve] (fetch "http://some.service.com" #(resolve %))))
;; can also be completed from outside (complete (promise) :done)
Used to get values out of callbacks.
ex:
;; some fn that takes a callback
(defn fetch [url callback] ...)
;; can be used as
(def p
(promise [resolve]
(fetch "http://some.service.com" #(resolve %))))
;; can also be completed from outside
(complete (promise) :done)(promise? obj)Returns true if obj is a CompletableFuture.
Returns `true` if obj is a `CompletableFuture`.
(with-async-executor executor & body)async blocks in body will run on
the given ExecutorService's threadpool.
`async` blocks in body will run on the given `ExecutorService`'s threadpool.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |