Re: Update an item from a list of maps in STM transaction

2012-04-02 Thread Stephen Compall
On Sat, 2012-03-31 at 11:00 -0700, Marcelo Macedo de Melo Silva wrote:
> I'm running multiple threads using this same list and need to update
> the value of an item inside a STM transaction.

If you mean by "value of an item" the value in the database: I suggest
you create an updater agent instead, shared by all the threads.  While
each thread is in a transaction, it can `send' an action to update the
database to this agent.  Agent sends are queued by the STM, so you can
be sure only one update happens, and only if a transaction succeeds.

If you mean to mutate the list of maps, you can't do that.

> I tried using one FUTURE for a REF but is not working.

Not sure what this means.  Futures are IDerefs...

-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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


Update an item from a list of maps in STM transaction

2012-04-02 Thread Marcelo Macedo de Melo Silva
friends,

I have the following situation:

I have a list of maps (obtained from the database with contrib.sql)
which is generated through a FUTURE.

I'm running multiple threads using this same list and need to update
the value of an item inside a STM transaction.

I tried using one FUTURE for a REF but is not working.

Some of you have an idea how I can do this?

I appreciate the help!

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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