Dereferencing a delivered promise will throw an InterruptedException
when the calling thread is interrupted:
(let [p (promise)]
(deliver p :value)
(.interrupt (Thread/currentThread))
(assert (realized? p))
(deref p)) ;; => InterruptedException
This is unexpected, as retrieving the value of a realized promise should not block.
Using CompletableFuture
through the Promesa library does not throw:
(require '[promesa.core :as p]) ;'
(let [p (p/deferred)]
(p/resolve! p :value)
(.interrupt (Thread/currentThread))
(deref p)) ;; => ::value