Public Member Functions | |
Buffer (int &epollFd_, 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. | |
int & | epollFd |
A reference to Transceiver::epollFd for removing file descriptors from epollFd 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(). | |
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... |
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 127 of file transceiver.hpp.
Fastcgipp::Transceiver::Buffer::Buffer | ( | int & | epollFd_, | |
std::map< int, fdBuffer > & | fdBuffers_ | |||
) | [inline] |
Constructor.
[out] | epollFd_ | A reference to Transceiver::epollFd is needed for removing file descriptors from epollFd 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 184 of file transceiver.hpp.
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 191 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 53 of file transceiver.cpp.
References chunks, frames, minBlockSize, Fastcgipp::Transceiver::Buffer::Chunk::size, and writeIt.
Referenced by Fastcgipp::Transceiver::secureWrite().
SendBlock Fastcgipp::Transceiver::Buffer::requestRead | ( | ) | [inline] |
Request a block of data for transmitting.
Definition at line 227 of file transceiver.hpp.
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 138 of file transceiver.cpp.
References chunks, epollFd, fdBuffers, frames, pRead, and writeIt.
Referenced by Fastcgipp::Transceiver::transmit().
bool Fastcgipp::Transceiver::Buffer::empty | ( | ) | [inline] |
Test of the buffer is empty.
Definition at line 241 of file transceiver.hpp.
References pRead, and writeIt.
Referenced by Fastcgipp::Transceiver::transmit().
std::queue<Frame> Fastcgipp::Transceiver::Buffer::frames [private] |
Queue of frames waiting to be transmitted.
Definition at line 147 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 149 of file transceiver.hpp.
Referenced by secureWrite().
std::list<Chunk> Fastcgipp::Transceiver::Buffer::chunks [private] |
A list of chunks. Can contain from 2-infinity.
Definition at line 167 of file transceiver.hpp.
Referenced by freeRead(), and secureWrite().
std::list<Chunk>::iterator Fastcgipp::Transceiver::Buffer::writeIt [private] |
Iterator pointing to the chunk currently used for writing.
Definition at line 169 of file transceiver.hpp.
Referenced by empty(), freeRead(), requestWrite(), and secureWrite().
char* Fastcgipp::Transceiver::Buffer::pRead [private] |
Current read spot in the buffer.
Definition at line 172 of file transceiver.hpp.
Referenced by empty(), freeRead(), and requestRead().
int& Fastcgipp::Transceiver::Buffer::epollFd [private] |
A reference to Transceiver::epollFd for removing file descriptors from epollFd when they are closed.
Definition at line 175 of file transceiver.hpp.
Referenced by freeRead().
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 177 of file transceiver.hpp.
Referenced by freeRead().