Manage a pool of connections.
CAUTION: Methods should be called under the protection of a lock. This class does no locking of its own.
There's no limit on the number of connections this can keep track of, but a warning is logged if there are more than pool_size active connections, and a critical problem if more than twice pool_size.
New connections are registered via push(). This will log a message if "too many" connections are active.
When a connection is explicitly closed, tell the pool via repush(). That adds the connection to a stack of connections available for reuse, and throws away the oldest stack entries if the stack is too large. pop() pops this stack.
When a connection is obtained via pop(), the pool holds only a weak reference to it thereafter. It's not necessary to inform the pool if the connection goes away. A connection handed out by pop() counts against pool_size only so long as it exists, and provided it isn't repush()'ed. A weak reference is retained so that DB methods like connectionDebugInfo() can still gather statistics.
There are no implemented interfaces.
There are no attributes in this class.
map(f)
For every live connection c, invoke f(c).
pop()
Pop an available connection and return it.
Return None if none are available - in this case, the caller should create a new connection, register it via push(), and call pop() again. The caller is responsible for serializing this sequence.
push(c)
Register a new available connection.
We must not know about c already. c will be pushed onto the available stack even if we're over the pool size limit.
repush(c)
Reregister an available connection formerly obtained via pop().
This pushes it on the stack of available connections, and may discard older available connections.
set_pool_size(pool_size)
Change our belief about the expected maximum # of live connections.
If the pool_size is smaller than the current value, this may discard the oldest available connections.
There are no known subclasses.