Description
We use a buffer pool to hold buffers uses during I/O (i.e. sending and receiving message). Using a buffer pool helps reduce the amount of work the garbage collection must do.
We currently have a single static ByteBufferFactory which gets its chunks from exactly one kind of pool, a BsonChunkPool.
It would be good to abstract the notion of a buffer pool to an interface to enable us to have multiple implementations.
This interface could look like:
public interface IBsonChunkSource : IDisposable
|
{
|
IBsonChunk GetChunk(int requestedSize);
|
}
|
What are actually pooled are chunks, not entire buffers, which are made up of multiple chunks.
I think it's better that the name of the interface not include the word "Pool", since the source may or may not involve a pool.