Re: Writing a put-if-absent operation a la Java's ConcurrentMap

2010-03-05 Thread Steven E. Harris
Stuart Halloway writes: > It is mort important to focus on the semantics (commutative or last- > one-wins) than the implementation details. That's a tough pill to swallow. I understand the benefits of specifying behavior to allow flexibility in an implementation, but here I think the behavior is

Re: Writing a put-if-absent operation a la Java's ConcurrentMap

2010-03-02 Thread Stuart Halloway
If so, there's more to be explained about `commute'. I'm imagining the commit-time rules saying that if competing changes to the refs touched by `commute' can be ignored, because the changes can be applied in either order. But if the operation was something like `inc', two competing threads would

Re: Writing a put-if-absent operation a la Java's ConcurrentMap

2010-03-02 Thread Steven E. Harris
Meikel Brandmeyer writes: > So using alter is the absolutely correct and nothing bad will > happen. However you might construct superfluous default nodes in case > the action is retried. They are not assoc'd to the map, though. Understood. Thanks for the explanation. > The anonymous function i

Re: Writing a put-if-absent operation a la Java's ConcurrentMap

2010-03-01 Thread Meikel Brandmeyer
Hi, disclaimer: I'm completely incompetent in terms of the STM. The following is my understanding what happens. It might be completely wrong. Ignore at will. On Mar 2, 2:40 am, "Steven E. Harris" wrote: >   (dosync >     (or (*id-node-map* id) >         (alter *id-node-map* >                #(a