From 289c793a54c971e4a0626596faf6451b8d326415 Mon Sep 17 00:00:00 2001 From: Roland Weber Date: Fri, 14 Dec 2007 18:43:46 +0000 Subject: [PATCH] use Queue interface in ConnPoolByRoute git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@604252 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/impl/conn/tsccm/ConnPoolByRoute.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java index a64323c73..fa292f019 100644 --- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java +++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java @@ -32,6 +32,7 @@ package org.apache.http.impl.conn.tsccm; import java.util.HashMap; import java.util.Iterator; +import java.util.Queue; import java.util.LinkedList; import java.util.Map; @@ -66,10 +67,10 @@ public class ConnPoolByRoute extends AbstractConnPool { /** The list of free connections */ - private LinkedList freeConnections; + private Queue freeConnections; /** The list of WaitingThreads waiting for a connection */ - private LinkedList waitingThreads; + private Queue waitingThreads; /** * A map of route-specific pools. @@ -113,6 +114,7 @@ public class ConnPoolByRoute extends AbstractConnPool { public ConnPoolByRoute(ClientConnectionManager mgr) { super(mgr); + //@@@ use factory method, at least for waitingThreads freeConnections = new LinkedList(); waitingThreads = new LinkedList(); routeToPool = new HashMap(); @@ -239,7 +241,7 @@ public class ConnPoolByRoute extends AbstractConnPool { } rospl.waitingThreads.addLast(waitingThread); - waitingThreads.addLast(waitingThread); + waitingThreads.add(waitingThread); wait(timeToWait); } catch (InterruptedException e) { @@ -412,7 +414,7 @@ public class ConnPoolByRoute extends AbstractConnPool { //@@@ with get() instead of remove, we could //@@@ leave the removing to deleteEntry() - BasicPoolEntry entry = (BasicPoolEntry) freeConnections.removeFirst(); + BasicPoolEntry entry = freeConnections.remove(); if (entry != null) { deleteEntry(entry); @@ -465,7 +467,7 @@ public class ConnPoolByRoute extends AbstractConnPool { if (LOG.isDebugEnabled()) { LOG.debug("Notifying thread waiting on any pool."); } - waitingThread = waitingThreads.removeFirst(); + waitingThread = waitingThreads.remove(); waitingThread.pool.waitingThreads.remove(waitingThread); } else if (LOG.isDebugEnabled()) {