C Collections

chttpclient · Section 3

chttpcli_set_pool_size

chttpcli_set_pool_size - set the connection pool size

C Collections (libccollections, -lccollections)

#include <ccollections/chttpclient.h>
 
ccol_retval chttpcli_set_pool_size(chttpcli cli, size_t n);

This function sets how many requests can be in flight at the same
time. When the client is at that limit, a caller of chttpcli_do
blocks until a slot is free.
 
The cap applies only to Tier 1 (chttpcli_do and
chttpcli_do_streaming), and neither to Tier 2 (chttpcli_do_async
and chttpcli_do_async_streaming) nor to Tier 3
(chttpcli_do_pooled and chttpcli_do_pooled_streaming). You can
submit any number of those requests at once, the shared async engine
handles all of them, and a submit never blocks.
 
An n of 0 selects the CPU count, which is the default.
 
You can call this function before or after the client's first request,
and it takes effect at once. When the limit grows, the client wakes
every waiting caller with a broadcast. This is purely a concurrency
cap and has nothing to do with the keep-alive cache of idle
connections, which has its own fixed internal caps per origin and in
total.

cli   The client handle. It must not be CHTTPCLI_NULL.
n     The pool size. 0 means the CPU count.

ccol_success            The client has the new pool size.
ccol_invalid_args       cli is CHTTPCLI_NULL, or a stale handle
                        of a client that has been destroyed.

chttpcli_create(3), chttpcli_do(3)