fastcgi++
|
Buffer type for transmission of FastCGI records More...
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 Member Functions | |
void | freeFd (int fd_) |
Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers) |
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() |
Buffer type for transmission of FastCGI records
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.
|
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 194 of file transceiver.hpp.
|
inline |
Test of the buffer is empty.
Definition at line 251 of file transceiver.hpp.
References pRead, and writeIt.
Referenced by Fastcgipp::Transceiver::transmit().
|
inlineprivate |
Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers)
Definition at line 187 of file transceiver.hpp.
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 158 of file transceiver.cpp.
Referenced by Fastcgipp::Transceiver::transmit().
|
inline |
Request a block of data for transmitting.
Definition at line 237 of file transceiver.hpp.
Referenced by Fastcgipp::Transceiver::transmit().
|
inline |
Request a write block in the buffer.
[in] | size | Requested size of write block |
Definition at line 201 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.
Referenced by Fastcgipp::Transceiver::secureWrite().
|
private |
A list of chunks. Can contain from 2-infinity.
Definition at line 175 of file transceiver.hpp.
|
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 freeFd().
|
private |
Queue of frames waiting to be transmitted.
Definition at line 155 of file transceiver.hpp.
Referenced by requestRead().
|
staticprivate |
Minimum Block size value that can be returned from requestWrite()
Definition at line 157 of file transceiver.hpp.
|
private |
A reference to Transceiver::pollFds for removing file descriptors when they are closed.
Definition at line 183 of file transceiver.hpp.
Referenced by freeFd().
|
private |
Current read spot in the buffer.
Definition at line 180 of file transceiver.hpp.
Referenced by empty(), and requestRead().
|
private |
Iterator pointing to the chunk currently used for writing.
Definition at line 177 of file transceiver.hpp.
Referenced by empty(), and requestWrite().