store/[org.clojure/clojure "1.8.0"] clj::clojure.core/dosync

Official Documentation

Add notes
Arities
==================================================
   [& exprs]

Docstring
==================================================
  Runs the exprs (in an implicit do) in a transaction that encompasses
  exprs and any nested calls.  Starts a transaction if none is already
  running on this thread. Any uncaught exception will abort the
  transaction and flow out of dosync. The exprs may be run more than
  once, but any effects on Refs will be atomic.

Source

(defmacro dosync
  "Runs the exprs (in an implicit do) in a transaction that encompasses
  exprs and any nested calls.  Starts a transaction if none is already
  running on this thread. Any uncaught exception will abort the
  transaction and flow out of dosync. The exprs may be run more than
  once, but any effects on Refs will be atomic."
  {:added "1.0"}
  [& exprs]
  `(sync nil ~@exprs))

Example 1

Edit
;; Keep dosync body free of side-effects:
(defn my-thread-unsafe-fn [important-ref]
  (let [start-work (ref false)]
    (dosync
     (when (not @important-ref)
       ;; "If a conflict occurs between 2 transactions 
       ;; trying to modify the same reference,
       ;; one of them will be retried."
       ;; http://clojure.org/concurrent_programming
       (ref-set important-ref true)
       (ref-set start-work true)))
    (when @start-work 
      ;; launch side-effects here
)))

Uses on crossclj