Bugfix/2530 atomic requests buffer size#2532
Conversation
de86199 to
f27fd8b
Compare
|
Thanks for the PR. The idea of avoiding the blocking
For load balancing among multiple requestsBuffer_.size() + pipeliningCallbacks_.size()or we should introduce a separate API with clearer semantics. Could you please update the PR to account for in-flight requests as well, and ideally add a test covering this case? |
|
Understood! I'll take a look at how |
ca8477b to
ae49def
Compare
|
PR Summary:
|
…with lock-free atomic - Introduced `outstandingRequests()` to `HttpClient` to reflect total connection load (buffered requests + in-flight pipelined requests). - Implemented an `std::atomic<std::size_t>` tracker for `pipeliningCallbacks_` for inspection of in-flight requests from the main thread. - Retained helper functions for `requestsBuffer_` to safely guard `std::list` mutations. - Added `HttpClientOutstandingRequests` integration test using `PipeliningTest::normalPipe`.
ae49def to
4902ba6
Compare
Fixes Issue #2530
Description:
Replaced the
std::promise/std::futureimplementation inrequestsBufferSize()with anstd::atomic<std::size_t>. Previously, calling this method from outside the event loop forced a cross-thread future resolution, blocking the calling thread entirely and preventing efficient async connection pooling.This PR centralizes the requestsBuffer_ mutations (push_back, pop_front, erase) to safely track the queue depth natively within the background thread. Reads now use
std::memory_order_relaxedfor zero-overhead, non-blocking execution.Testing Performed: