A concurrent connection cache for passively created connections (e.g.
from an acceptor). Here a Connection is an
abstraction of a Socket or SocketChannel: basically some sort of resource
that is expensive to acquire, and can be re-used freely.
The cache maintains a loose
upper bound on the number of cached connections, and reclaims connections as
needed.
This cache places minimal requirements on the Connections that it contains:
- A Connection must implement a close() method. This is called when idle
connections are reclaimed.
- A Connection must be usable as a HashMap key.
Some simple methods are provided for monitoring the state of the cache:
numbers of busy and idle connections, and the total number of
connections in the cache.
Access is also provided to the cache configuration: maxParallelConnections,
highWaterMark, and numberToReclaim. Currently these can only be set when
the cache is created.
XXX We may wish to make the cache configuration dynamically configurable. |