Hi Tim,
I suppose that this depends on whether RESOLVE_ROOT changes state
somewhere or not. If it really results in a read-only operation
without any side effects, I think that the lock in the getter can be
changed into a READ lock.
Hope this helps,
Geert
On 21 Aug 2007, at 01:08, Tim Eck wrote:
> Just wanted to throw this out to see if I’m overlooking something….
>
>
>
> I noticed that the methods for getting and setting root fields both
> use WRITE locks (see psuedocode below):
>
>
>
> public class Root {
>
> Object root;
>
>
>
> Object rootGetter() {
>
> if (root == null) {
>
> DSOLock("Root.root", WRITE); // <-- XXX: is READ okay here?
>
> try {
>
> root = RESOLVE_ROOT("Root.root");
>
> } finally {
>
> DSOUnlock("Root.root");
>
> }
>
> }
>
> return root;
>
> }
>
>
>
> void rootSetter(Object root) {
>
> if (root != null) {
>
> DSOLock("Root.root", WRITE);
>
> try {
>
> LOOKUP_OR_CREATE_ROOT("Root.root", root);
>
> } finally {
>
> DSOUnlock("Root.root");
>
> }
>
> }
>
> }
>
> }
>
>
>
> I’m wondering it makes sense to use a READ lock for the root
> getter? For regular non-primitive roots this will only help the
> case when reading roots with null values (which presently means
> never initialized). For primitive roots, the situation is a little
> worse in that we do get the WRITE lock on every read since we don’t
> have a magic null marker for primitives.
>
>
>
> -tim
>
>
>
> _______________________________________________
> tc-dev mailing list
> [email protected]
> http://lists.terracotta.org/mailman/listinfo/tc-dev
--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
_______________________________________________
tc-dev mailing list
[email protected]
http://lists.terracotta.org/mailman/listinfo/tc-dev