From b54aa3fce5e493f8bc397fe28fefaac82c449407 Mon Sep 17 00:00:00 2001 From: fhanik Date: Wed, 29 Oct 2008 02:15:35 +0000 Subject: [PATCH] Fix the performance issue, don't count down until the lock has been released, this allows for much more concurrency git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708753 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java b/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java index f60a7a25b..477d8c9e4 100644 --- a/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java +++ b/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java @@ -50,17 +50,18 @@ public class FairBlockingQueue implements BlockingQueue { public boolean offer(E e) { final ReentrantLock lock = this.lock; lock.lock(); + ExchangeCountDownLatch c = null; try { if (waiters.size() > 0) { - ExchangeCountDownLatch c = waiters.poll(); + c = waiters.poll(); c.setItem(e); - c.countDown(); } else { items.add(e); } } finally { lock.unlock(); } + if (c!=null) c.countDown(); return true; } -- 2.11.0