missionary.core/!
Usage
(!)
The interruption checking synchronizer. Throws an instance of Cancelled
if current evaluation context is interrupted, otherwise returns nil
.
Example : explicit interruption check when an asynchronous operation doesn't support it.
(require '[missionary.core :as m]) ;; slurp is not interruptible (def fetch-page (m/via m/blk (slurp "https://clojure.org"))) ;; this is a long-lived task, it must terminate on cancellation ;; the interruption status is polled inside the loop (def repeat-fetch (m/sp (loop [] (m/? fetch-page) (m/!) (recur)))) ;; without interruption check, the call would never return ;; because timeout waits for repeat-fetch termination (m/? (m/timeout repeat-fetch 500 :timeout)) := :timeout
Synchronicity
- interruption checking return is synchronous with the call.