> 
> A related question.  If I wanted to do a once-off initialization of the value 
> (ie, the first VM to create the distributed ref will set the value) how would 
> I go about it?
> 

I would just create the Ref without an initial value, and if the current value 
is non-nil, you know that it has already been initialized.

> 
> I think I've narrowed down what was triggering the problem for me.  In my 
> code I had something like this:
> 
>     (dosync!! client
>               (alter!! r0 inc)
>               (alter!! r1 conj @r0)
>               (Thread/sleep 20000))
> 
> If I deref r1 in the second VM before the thread has finished sleeping I get 
> the expected (unmodified) value. Once the thread finishes sleeping if I deref 
> it again it doesn't update.  If instead I wait until after the thread 
> finishes before doing the deref then it shows the correct value.
> 
> Let me know if you still can't reproduce it and I'll try to provide more 
> detail.

That was perfect, the problem occurs because I was invalidating the cache as 
soon as the alter!! function was called, you then deref-ed it on the VM, which 
asked for the current value (because it's cache had just been invalidated) 
where it received the unmodified version (and cached it), then the commit 
occurs on the first VM without invalidating the cache again. 

So, I've changed the strategy, I invalidate the cache at commit instead of at 
alter!! (actually doSet), which causes your example to work correctly.

The new version is:

[Avout 0.5.3]

Let me know if you run into any other issues.

Thanks for the feedback,
David

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