pub fn resize(pool: *ConnectionPool, io: Io, new_size: usize) Io.Cancelable!void pool: *ConnectionPoolio: Ionew_size: usize163
164
165
166
167
168
169
170
171
172
173
174
175 pub fn resize(pool: *ConnectionPool, io: Io, new_size: usize) Io.Cancelable!void {
try pool.mutex.lock(io);
defer pool.mutex.unlock(io);
while (pool.free_len > new_size) {
const popped: *Connection = @alignCast(@fieldParentPtr("pool_node", pool.free.popFirst().?));
pool.free_len -= 1;
popped.destroy(io);
}
pool.free_size = new_size;
}
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.