I came across a thread from Jul '08 which seems to be the definitive
on handling side-effects within transactions -
http://groups.google.co.za/group/clojure/browse_thread/thread/d645d77a8b51f01/667e833c1ea381d7

Adrian.

On Wed, Apr 1, 2009 at 9:24 AM, Timothy Pratley
<timothyprat...@gmail.com> wrote:
>
> Hi Korny,
>
>
> That is a very interesting question to me, specifically this part:
>
>> how do I stop parallel
>> changes to two unrelated structures in the world from causing transaction
>> retries?
>
> Actually I don't think you can ever rule out retries if you are using
> a ref (or atom) and more than one thread to access it. For me this
> poses a problem because my 'transaction' has side-effects. I have a
> function which modifies the state, but it also reports the
> modification (reporting should only happen once). I can think of two
> solutions:
> (1) Use an agent instead - changes are coordinated on a queue and the
> modification is only run once.
> (2) Use watchers to do the reporting.
> Neither of these are particularly appealing to me as (1) is
> asynchronous and (2) appears to slightly complicate things. In my case
> it seems a regular old lock would be sufficient?
>
> There is a discussion on STM generally:
> http://groups.google.com/group/clojure/browse_thread/thread/822e21c9a36c5a0f/c81692a8dc1bd198
> But I'm still a little unsure what I should do in this situation.
>
>
> Regards,
> Tim.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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