On 3 December 2011 01:44, David Edgar Liebke <lie...@gmail.com> wrote:

> Hi Glen,
>
> >
> > The init-stm step is still referenced in the documentation as being
> required BTW.
> >
>
> Thanks, I'll remove the reference.
>
> > I had a couple of questions.
> >
> > I noticed that when I create a reference (zk-ref) I need to provide an
> initial value.  For each VM I do this for - it ends up clobbering the
> previous value.  Is there anyway to create a reference without necessarily
> clobbering existing data?
>
> Yep, like Chris said, you can just leave off the initial value when
> creating a Ref or Atom, just like with the in-memory versions.
>
>
Okay, thanks. Not sure how I missed the second arg list when I looked up
the docs.

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?



> >
> > My second question is to do with derefs. The documentation says that
> Avout caches multiple derefs and that it will invalidate the cache when the
> ref is locally or remotely updated.  My own testing seems to indicate that
> the deref still see the old values after a remote change is made.  If I
> wrap the deref in a dosync!! however that seems to trigger the invalidation
> and I see the correct value. Am I missing something?
> >
>
> I can't reproduce this behavior, can you provide a code snippet where the
> cache isn't getting invalidated and maybe some additional details on your
> setup?
>
>
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.

Regards,

Glen

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