The way I understand it, "transaction running" means that the code is
executing inside a dosync block. So this should work:


(def account1 (ref 1000))
(def account2 (ref 2000))

(dosync (map ensure [account1 account2]))


However, I get the following error:

java.lang.IllegalStateException: No transaction running


I use ensure rather than deref because I want to know that the result is
representative of all accounts at the same point in time. I intended to use
this as a trivial example of STM for a Clojure presentation, and was
surprised when it didn't work.

Why can't I use ensure inside of a dosync block? Is there another way to
perform a transaction?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to