ConnectionPool
ConnectionPool
#include <icy/http/server.h>class ConnectionPoolDefined in src/http/include/icy/http/server.h:291
LIFO connection pool for reusing ServerConnection objects. Avoids per-request heap allocation by resetting and reusing connections instead of destroying and recreating them.
List of all members
| Name | Kind | Owner |
|---|---|---|
acquire | function | Declared here |
release | function | Declared here |
setMaxSize | function | Declared here |
size | function | Declared here |
_pool | variable | Declared here |
_maxSize | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
ServerConnection::Ptr | acquire inline | Takes a connection from the pool for reuse. |
bool | release inline | Returns a connection to the pool after use. |
void | setMaxSize inline | Sets the maximum number of connections the pool will hold. |
size_t | size const inline | Returns the current number of connections held in the pool. |
acquire
inline
inline ServerConnection::Ptr acquire()Defined in src/http/include/icy/http/server.h:296
Takes a connection from the pool for reuse.
Returns
A pooled connection, or nullptr if the pool is empty.
release
inline
inline bool release(ServerConnection::Ptr & conn)Defined in src/http/include/icy/http/server.h:307
Returns a connection to the pool after use.
Parameters
connThe connection to return.
Returns
true if accepted into the pool; false if the pool is full.
setMaxSize
inline
inline void setMaxSize(size_t n)Defined in src/http/include/icy/http/server.h:316
Sets the maximum number of connections the pool will hold.
Parameters
nMaximum pool capacity.
size
const inline
inline size_t size() constDefined in src/http/include/icy/http/server.h:319
Returns the current number of connections held in the pool.
Private Attributes
_pool
std::vector< ServerConnection::Ptr > _poolDefined in src/http/include/icy/http/server.h:322
_maxSize
size_t _maxSize = 128