mbrodersen wrote:
>> Using atoms is not a good idea. Unless you don't mind if the same
>> message is sometimes printed more than once. Atoms are implemented
>> using spin locks with automatic retry.
> 
> Hmmm...unless add-watch => observer is called only once.

Looking in clojure/lang/Atom.java:

public Object swap(IFn f) throws Exception{
        for(; ;)
                {
                Object v = deref();
                Object newv = f.invoke(v);
                validate(newv);
                if(state.compareAndSet(v, newv))
                        {
                        notifyWatches(v, newv);
                        return newv;
                        }
                }
}

So I guess that'd be a yes, it's only called once.

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

Reply via email to