On Wed, Sep 16, 2009 at 11:28 PM, Krukow <karl.kru...@gmail.com> wrote:
>
> Final question. The docs say that 'ensure' permits more concurrency
> than promoting the ref to a write. Is there a quick/simple way of
> explaining how? (Or do I need to go to the source :-)

When you call ensure on a Ref, the current LockingTransaction acquires
a read lock on the Ref from its ReentrantReadWriteLock. That means
other transactions can read (or dereference) the Ref, but not write
it.

When you modify a Ref, the doSet method in LockingTransaction is
called. That calls the lock method in LockingTransaction which sets
the tinfo field in the Ref. Setting tinfo serves as an indication that
the Ref has an active writer. Like with ensure, this means other
transactions can read the Ref, but not write it.

It's not clear to me that one of these situations allows more
concurrency than the other. Both prevent other writers and allow other
readers. If using ensure really does permit more concurrency, I'd also
like to understand how.

-- 
R. Mark Volkmann
Object Computing, Inc.

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