You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/16 20:50:31 UTC
[10/44] git commit: TAP5-1929: Performance improvements Extend the
lazy initialization reentrant lock to conver the conduits NamedSet as well
TAP5-1929: Performance improvements
Extend the lazy initialization reentrant lock to conver the conduits NamedSet as well
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/df6e407d
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/df6e407d
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/df6e407d
Branch: refs/heads/master
Commit: df6e407db1ffd786f696630c411fd6bf5d2e7968
Parents: 67f637d
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Mon May 14 09:26:20 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:50:14 2012 -0700
----------------------------------------------------------------------
.../structure/InternalComponentResourcesImpl.java | 61 ++++++++++++---
1 files changed, 51 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/df6e407d/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
index 852130b..7274e73 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
@@ -88,7 +88,7 @@ public class InternalComponentResourcesImpl implements InternalComponentResource
// Maps from parameter name to ParameterConduit, used to support mixins
// which need access to the containing component's PC's
- // Guarded by this
+ // Guarded by: lazyCreationLock
private NamedSet<ParameterConduit> conduits;
// Guarded by: lazyCreationLock
@@ -644,27 +644,68 @@ public class InternalComponentResourcesImpl implements InternalComponentResource
page.addResetListener(listener);
}
- private synchronized void resetParameterConduits()
+ private void resetParameterConduits()
{
- if (conduits != null)
+ try
+ {
+ lazyCreationLock.readLock().lock();
+
+ if (conduits != null)
+ {
+ conduits.eachValue(RESET_PARAMETER_CONDUIT);
+ }
+ } finally
{
- conduits.eachValue(RESET_PARAMETER_CONDUIT);
+ lazyCreationLock.readLock().unlock();
}
}
- public synchronized ParameterConduit getParameterConduit(String parameterName)
+ public ParameterConduit getParameterConduit(String parameterName)
{
- return NamedSet.get(conduits, parameterName);
+ try
+ {
+ lazyCreationLock.readLock().lock();
+ return NamedSet.get(conduits, parameterName);
+ } finally
+ {
+ lazyCreationLock.readLock().unlock();
+ }
}
- public synchronized void setParameterConduit(String parameterName, ParameterConduit conduit)
+ public void setParameterConduit(String parameterName, ParameterConduit conduit)
{
- if (conduits == null)
+ try
{
- conduits = NamedSet.create();
+ lazyCreationLock.readLock().lock();
+
+ if (conduits == null)
+ {
+ createConduits();
+ }
+
+ conduits.put(parameterName, conduit);
+ } finally
+ {
+ lazyCreationLock.readLock().unlock();
}
+ }
- conduits.put(parameterName, conduit);
+ private void createConduits()
+ {
+ try
+ {
+ lazyCreationLock.readLock().unlock();
+ lazyCreationLock.writeLock().lock();
+
+ if (conduits == null)
+ {
+ conduits = NamedSet.create();
+ }
+ } finally
+ {
+ lazyCreationLock.readLock().lock();
+ lazyCreationLock.writeLock().unlock();
+ }
}