You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/02/09 20:33:18 UTC
httpcomponents-core git commit: [HTTPCORE-509] AVAIL_PROCS is
auto-configured based on core count.
Repository: httpcomponents-core
Updated Branches:
refs/heads/master 07f436a5a -> 39eeb3a0f
[HTTPCORE-509] AVAIL_PROCS is auto-configured based on core count.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/39eeb3a0
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/39eeb3a0
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/39eeb3a0
Branch: refs/heads/master
Commit: 39eeb3a0f59fc227270e5363cff6e5ec57316781
Parents: 07f436a
Author: Gary Gregory <ga...@gmail.com>
Authored: Fri Feb 9 13:33:15 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Fri Feb 9 13:33:15 2018 -0700
----------------------------------------------------------------------
RELEASE_NOTES.txt | 3 ++
.../hc/core5/reactor/IOReactorConfig.java | 29 +++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/39eeb3a0/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 4fc6feb..bd0b8e0 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -10,6 +10,9 @@ adds several incremental improvements.
* HTTPCORE-511: Do not cache result of Runtime.getRuntime().availableProcessors() in IOReactorConfig.
Contributed by Gary Gregory <ggregory at apache.org>
+* HTTPCORE-509: AVAIL_PROCS is auto-configured based on core count.
+ Contributed by Gary Gregory <ggregory at apache.org>
+
Release 5.0-BETA2
-------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/39eeb3a0/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java
index 58e9754..7177234 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java
@@ -214,6 +214,33 @@ public final class IOReactorConfig {
public static class Builder {
+ private static int DefaultMaxIoThreadCount = -1;
+
+ /**
+ * Gets the default value for {@code ioThreadCount}. Returns
+ * {@link Runtime#availableProcessors()} if
+ * {@link #setDefaultMaxIoThreadCount(int)} was called with a value <=0.
+ *
+ * @return the default value for ioThreadCount.
+ * @since 4.4.10
+ */
+ public static int getDefaultMaxIoThreadCount() {
+ return DefaultMaxIoThreadCount > 0 ? DefaultMaxIoThreadCount : Runtime.getRuntime().availableProcessors();
+ }
+
+ /**
+ * Sets the default value for {@code ioThreadCount}. Use a value <= 0 to
+ * cause {@link #getDefaultMaxIoThreadCount()} to return
+ * {@link Runtime#availableProcessors()}.
+ *
+ * @param defaultMaxIoThreadCount
+ * the default value for ioThreadCount.
+ * @since 4.4.10
+ */
+ public static void setDefaultMaxIoThreadCount(final int defaultMaxIoThreadCount) {
+ DefaultMaxIoThreadCount = defaultMaxIoThreadCount;
+ }
+
private long selectInterval;
private int ioThreadCount;
private Timeout soTimeout;
@@ -227,7 +254,7 @@ public final class IOReactorConfig {
Builder() {
this.selectInterval = 1000;
- this.ioThreadCount = Runtime.getRuntime().availableProcessors();
+ this.ioThreadCount = Builder.getDefaultMaxIoThreadCount();
this.soTimeout = Timeout.ZERO_MILLISECONDS;
this.soReuseAddress = false;
this.soLinger = TimeValue.NEG_ONE_SECONDS;