On Feb 8, 7:29 pm, Shawn Hoover <shawn.hoo...@gmail.com> wrote: > On Sun, Feb 8, 2009 at 12:23 PM, Anand Patil < > > anand.prabhakar.pa...@gmail.com> wrote: > > > Hello again, > > > In my application, I'll frequently want to quickly discard all the > > changes made during a transaction involving many refs. I don't want to > > force the refs to roll back to their values at the beginning of the > > transaction, I just want to end the transaction immediately and skip > > the write stage; updates made in other transactions should still > > 'stick'. What's the most efficient way to do this? > > > Thanks again! > > Anand > > You can abort a transaction by throwing an exception, but in that case all > refs automatically retain their pre-transaction values. You can't partially > roll back a transaction, because by definition all changes to refs in a > transaction occur or none do. > > By the way, what do you mean by "other transactions"? > - Transactions running on other threads? Aborting in one thread does not > affect refs in other threads. > - Transactions that completed earlier in time on the same thread? Those > values are not affected by aborting a later transaction. > - dosync calling dosync on the same on the same thread? Aborting from an > inner dosync aborts the whole stack of dosyncs in that thread.
I think your first response covers my case. Here's an example of what I mean: (def a (ref 1)) (def b (ref 1)) ; Do these concurrently, either from separate agents or using pmap (dosync (commute b error-throwing-fn a)) (dosync (commute a + @b)) I want to have the option to abort the first transaction without rolling back the second. Based on what you said, if the first transaction is aborted but the second is not then no matter what a's value will be 2 and b's value will be 1, correct? Thanks for the replies, Anand --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---