vswap!

added
1.7

ns
clojure.core

type
macro

(vswap! vol f & args)

Non-atomically swaps the value of the volatile as if:
(apply f current-value-of-vol args). Returns the value that
was swapped in.

                (let [interrupt (volatile! false)
      f1 (future (Thread/sleep 1000)
                 (vswap! interrupt not))
      f2 (future (while (not @interrupt)
                        (println "Another cycle!")
                        (Thread/sleep 100)))]
  @f1
  @f2)