ClojureDocs

Nav

Namespaces

vswap!

clojure.core

Available since 1.7 (source)
  • (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.
1 Example
(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)
See Also

Creates and returns a Volatile with an initial value of val.

Added by kumarshantanu

Sets the value of volatile to newval without regard for the current value. Returns newval.

Added by didibus

Returns true if x is a volatile.

Added by didibus

Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be...

Added by didibus
0 Notes
No notes for vswap!