From: fhanik Date: Wed, 26 Nov 2008 03:54:38 +0000 (+0000) Subject: Add the ability to configure multiple pollers and default them to number of CPUs X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8e435eb742cb0b9b966cb7f36b01ac15e7cecddb;p=tomcat7.0 Add the ability to configure multiple pollers and default them to number of CPUs git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@720728 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 9423b9c29..92e24b55c 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -490,7 +490,7 @@ public class NioEndpoint { /** * Poller thread count. */ - protected int pollerThreadCount = 1; + protected int pollerThreadCount = Runtime.getRuntime().availableProcessors(); public void setPollerThreadCount(int pollerThreadCount) { this.pollerThreadCount = pollerThreadCount; } public int getPollerThreadCount() { return pollerThreadCount; } @@ -500,9 +500,15 @@ public class NioEndpoint { /** * The socket poller. */ - protected Poller poller = null; + protected Poller[] pollers = null; + protected AtomicInteger pollerRotater = new AtomicInteger(0); + /** + * Return an available poller in true round robin fashion + * @return + */ public Poller getPoller0() { - return poller; + int idx = Math.abs(pollerRotater.incrementAndGet()) % pollers.length; + return pollers[idx]; } /** @@ -695,10 +701,14 @@ public class NioEndpoint { * Number of keepalive sockets. */ public int getKeepAliveCount() { - if (poller == null) { + if (pollers == null) { return 0; } else { - return poller.selector.keys().size(); + int sum = 0; + for (int i=0; i