sync vs. dosync

138 views
Skip to first unread message

Mark Volkmann

unread,
Dec 26, 2008, 2:44:51 PM12/26/08
to clo...@googlegroups.com
What is the difference between the sync and dosync functions? Their
documentation strings are identical.

--
R. Mark Volkmann
Object Computing, Inc.

Michael Wood

unread,
Dec 26, 2008, 3:50:21 PM12/26/08
to clo...@googlegroups.com
On Fri, Dec 26, 2008 at 9:44 PM, Mark Volkmann
<r.mark....@gmail.com> wrote:
>
> What is the difference between the sync and dosync functions? Their
> documentation strings are identical.

sync has an extra flags argument. At the moment they are the same,
but presumably sync will do different things depending on the flags in
future.

Here is how they are currently defined:

(defmacro sync
"transaction-flags => TBD, pass nil for now

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 sync. The exprs may be run more than
once, but any effects on Refs will be atomic."
[flags-ignored-for-now & body]
`(. clojure.lang.LockingTransaction
(runInTransaction (fn [] ~@body))))

(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."
[& exprs]
`(sync nil ~@exprs))

--
Michael Wood <esio...@gmail.com>

Reply all
Reply to author
Forward
0 new messages