Return-Path: X-Original-To: apmail-tapestry-commits-archive@minotaur.apache.org Delivered-To: apmail-tapestry-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A6C2A99DE for ; Wed, 16 May 2012 18:50:34 +0000 (UTC) Received: (qmail 86140 invoked by uid 500); 16 May 2012 18:50:32 -0000 Delivered-To: apmail-tapestry-commits-archive@tapestry.apache.org Received: (qmail 85980 invoked by uid 500); 16 May 2012 18:50:32 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 85521 invoked by uid 99); 16 May 2012 18:50:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 18:50:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 884F416418; Wed, 16 May 2012 18:50:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hlship@apache.org To: commits@tapestry.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [10/44] git commit: TAP5-1929: Performance improvements Extend the lazy initialization reentrant lock to conver the conduits NamedSet as well Message-Id: <20120516185031.884F416418@tyr.zones.apache.org> Date: Wed, 16 May 2012 18:50:31 +0000 (UTC) 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 Authored: Mon May 14 09:26:20 2012 -0700 Committer: Howard M. Lewis Ship 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 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(); + } }