Function resize [src]
Resizes the connection pool.
If the new size is smaller than the current size, then idle connections will be closed until the pool is the new size.
Threadsafe.
Prototype
pub fn resize(pool: *ConnectionPool, allocator: Allocator, new_size: usize) void Parameters
pool: *ConnectionPoolallocator: Allocatornew_size: usize Source
pub fn resize(pool: *ConnectionPool, allocator: Allocator, new_size: usize) void {
pool.mutex.lock();
defer pool.mutex.unlock();
const next = pool.free.first;
_ = next;
while (pool.free_len > new_size) {
const popped = pool.free.popFirst() orelse unreachable;
pool.free_len -= 1;
popped.data.close(allocator);
allocator.destroy(popped);
}
pool.free_size = new_size;
}