Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
import org.apache.hc.core5.io.ModalCloseable;
import org.apache.hc.core5.pool.DisposalCallback;

/**
* {@link DisposalCallback} that defers graceful connection disposal so it can
* be executed outside core pool synchronization.
* <p>
* Calls with {@link CloseMode#IMMEDIATE} are delegated directly to the
* underlying callback on the caller thread. All other modes are queued and
* later disposed with {@link CloseMode#GRACEFUL} when {@link #drain()} is
* invoked by {@link PoolingHttpClientConnectionManager}.
*
* @since 5.6
*/
@Internal
final class OffLockDisposalCallback<T extends ModalCloseable> implements DisposalCallback<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.io.HttpConnectionFactory;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.pool.PoolConcurrencyPolicy;
import org.apache.hc.core5.pool.PoolReusePolicy;
import org.apache.hc.core5.util.TimeValue;
Expand Down Expand Up @@ -308,7 +309,17 @@ public final PoolingHttpClientConnectionManagerBuilder useSystemProperties() {
}

/**
* Enable/disable off-lock disposal.
* Enable or disable off-lock connection disposal for blocking I/O pools.
* <p>
* When enabled, graceful connection closes are deferred and performed
* outside the core pool synchronization in
* {@link PoolingHttpClientConnectionManager}. This reduces the time spent
* holding internal locks at the cost of slightly more complex disposal
* logic. Immediate closes {@link CloseMode#IMMEDIATE} are still executed
* on the caller thread.
*
* @param enabled {@code true} to enable off-lock disposal, {@code false} to disable
* @return this builder
* @since 5.6
*/
@Experimental
Expand All @@ -317,6 +328,7 @@ public final PoolingHttpClientConnectionManagerBuilder setOffLockDisposalEnabled
return this;
}


@Internal
protected HttpClientConnectionOperator createConnectionOperator(
final SchemePortResolver schemePortResolver,
Expand Down