Class BufferManager
Defined in File Buffer.hpp
Class Documentation
-
class BufferManager
Manages a set of buffers for TCP communication for one endpoint.
Provides functionality to request and return buffers.
Public Functions
-
explicit BufferManager(const ConnectionParameters ¶ms)
Constructs a BufferManager object.
- Parameters:
params – The connection parameters used to configure the buffers (number and size)
-
NetworkBuffer *getBuffer()
Retrieves a network buffer.
If no buffers are available, returns nullptr.
- Throws:
TcpNoBuffers – if no buffers were allocated
- Returns:
A pointer to the network buffer (or nullptr of none available)
-
void returnBuffer(const NetworkBuffer *buffer)
Returns a network buffer to the buffer manager.
- Throws:
std::invalid_argument – if the buffer is not of type Buffer
- Parameters:
buffer – The network buffer to return
-
void returnBuffer(Key key)
Returns a network buffer to the buffer manager.
- Parameters:
key – The key of the buffer to return
-
std::size_t getNumAvailableBuffers()
Retrieves the number of available buffers.
Returns the mininum number of available buffers since the last call to this function.
- Returns:
The number of available buffers
-
explicit BufferManager(const ConnectionParameters ¶ms)