Classes | |
struct | Chunk |
Chunk of data in Buffer More... | |
struct | Frame |
Frame of data associated with a file descriptor More... | |
struct | SendBlock |
Block of memory for extraction from Buffer More... | |
Public Member Functions | |
Buffer (std::vector< pollfd > &pollFds, std::map< int, fdBuffer > &fdBuffers_) | |
Constructor. | |
Block | requestWrite (size_t size) |
Request a write block in the buffer. | |
void | secureWrite (size_t size, Protocol::FullId id, bool kill) |
Secure a write in the buffer. | |
SendBlock | requestRead () |
Request a block of data for transmitting. | |
void | freeRead (size_t size) |
Mark data in the buffer as transmitted and free it's memory. | |
bool | empty () |
Test of the buffer is empty. | |
Private Attributes | |
std::queue< Frame > | frames |
Queue of frames waiting to be transmitted. | |
std::list< Chunk > | chunks |
A list of chunks. Can contain from 2-infinity. | |
std::list< Chunk >::iterator | writeIt |
Iterator pointing to the chunk currently used for writing. | |
char * | pRead |
Current read spot in the buffer. | |
std::vector< pollfd > & | pollFds |
A reference to Transceiver::pollFds for removing file descriptors when they are closed. | |
std::map< int, fdBuffer > & | fdBuffers |
A reference to Transceiver::fdBuffer for deleting buffers upon closing of the file descriptor. | |
Static Private Attributes | |
static const unsigned int | minBlockSize = 256 |
Minimum Block size value that can be returned from requestWrite(). |
This buffer is implemented as a circle of Chunk objects; the number of which can grow and shrink as needed. Write space is requested with requestWrite() which thereby returns a Block which may be smaller than requested. The write is committed by calling secureWrite(). A smaller space can be committed than was given to write on.
All data written to the buffer has an associated file descriptor through which it is flushed. File descriptor association with data is managed through a queue of Frame objects.
Definition at line 135 of file transceiver.hpp.
Fastcgipp::Transceiver::Buffer::Buffer | ( | std::vector< pollfd > & | pollFds, | |
std::map< int, fdBuffer > & | fdBuffers_ | |||
) | [inline] |
Constructor.
[out] | pollFds_ | A reference to Transceiver::pollFds is needed for removing file descriptors when they are closed |
[out] | fdBuffers_ | A reference to Transceiver::fdBuffer is needed for deleting buffers upon closing of the file descriptor |
Definition at line 192 of file transceiver.hpp.
bool Fastcgipp::Transceiver::Buffer::empty | ( | ) | [inline] |
Test of the buffer is empty.
Definition at line 249 of file transceiver.hpp.
References pRead, and writeIt.
Referenced by Fastcgipp::Transceiver::transmit().
void Fastcgipp::Transceiver::Buffer::freeRead | ( | size_t | size | ) |
Mark data in the buffer as transmitted and free it's memory.
size | Amount of bytes to mark as transmitted and free |
Definition at line 151 of file transceiver.cpp.
References chunks, fdBuffers, frames, pollFds, pRead, and writeIt.
Referenced by Fastcgipp::Transceiver::transmit().
SendBlock Fastcgipp::Transceiver::Buffer::requestRead | ( | ) | [inline] |
Request a block of data for transmitting.
Definition at line 235 of file transceiver.hpp.
Referenced by Fastcgipp::Transceiver::transmit().
Block Fastcgipp::Transceiver::Buffer::requestWrite | ( | size_t | size | ) | [inline] |
Request a write block in the buffer.
[in] | size | Requested size of write block |
Definition at line 199 of file transceiver.hpp.
References Fastcgipp::Transceiver::Buffer::Chunk::size, and writeIt.
Referenced by Fastcgipp::Transceiver::requestWrite().
void Fastcgipp::Transceiver::Buffer::secureWrite | ( | size_t | size, | |
Protocol::FullId | id, | |||
bool | kill | |||
) |
Secure a write in the buffer.
[in] | size | Amount of bytes to secure |
[in] | id | Associated complete ID (contains file descriptor) |
[in] | kill | Boolean value indicating whether or not the file descriptor should be closed after transmission |
Definition at line 54 of file transceiver.cpp.
References chunks, frames, minBlockSize, Fastcgipp::Transceiver::Buffer::Chunk::size, and writeIt.
Referenced by Fastcgipp::Transceiver::secureWrite().
std::list<Chunk> Fastcgipp::Transceiver::Buffer::chunks [private] |
A list of chunks. Can contain from 2-infinity.
Definition at line 175 of file transceiver.hpp.
Referenced by freeRead(), and secureWrite().
std::map<int, fdBuffer>& Fastcgipp::Transceiver::Buffer::fdBuffers [private] |
A reference to Transceiver::fdBuffer for deleting buffers upon closing of the file descriptor.
Definition at line 185 of file transceiver.hpp.
Referenced by freeRead().
std::queue<Frame> Fastcgipp::Transceiver::Buffer::frames [private] |
Queue of frames waiting to be transmitted.
Definition at line 155 of file transceiver.hpp.
Referenced by freeRead(), requestRead(), and secureWrite().
const unsigned int Fastcgipp::Transceiver::Buffer::minBlockSize = 256 [static, private] |
Minimum Block size value that can be returned from requestWrite().
Definition at line 157 of file transceiver.hpp.
Referenced by secureWrite().
std::vector<pollfd>& Fastcgipp::Transceiver::Buffer::pollFds [private] |
A reference to Transceiver::pollFds for removing file descriptors when they are closed.
Definition at line 183 of file transceiver.hpp.
Referenced by freeRead().
char* Fastcgipp::Transceiver::Buffer::pRead [private] |
Current read spot in the buffer.
Definition at line 180 of file transceiver.hpp.
Referenced by empty(), freeRead(), and requestRead().
std::list<Chunk>::iterator Fastcgipp::Transceiver::Buffer::writeIt [private] |
Iterator pointing to the chunk currently used for writing.
Definition at line 177 of file transceiver.hpp.
Referenced by empty(), freeRead(), requestWrite(), and secureWrite().