fastcgi++
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
Fastcgipp::Transceiver::Buffer Class Reference

Buffer type for transmission of FastCGI records More...

List of all members.

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< Frameframes
 Queue of frames waiting to be transmitted.
std::list< Chunkchunks
 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()

Detailed Description

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.


Constructor & Destructor Documentation

Fastcgipp::Transceiver::Buffer::Buffer ( std::vector< pollfd > &  pollFds_,
std::map< int, fdBuffer > &  fdBuffers_ 
) [inline]

Constructor.

Parameters:
[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.


Member Function Documentation

Test of the buffer is empty.

Returns:
true if the buffer is empty

Definition at line 251 of file transceiver.hpp.

References pRead, and writeIt.

Referenced by Fastcgipp::Transceiver::transmit().

void Fastcgipp::Transceiver::Buffer::freeFd ( int  fd_) [inline, private]

Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers)

Definition at line 187 of file transceiver.hpp.

References fdBuffers, and pollFds.

Mark data in the buffer as transmitted and free it's memory.

Parameters:
sizeAmount of bytes to mark as transmitted and free

Definition at line 158 of file transceiver.cpp.

Referenced by Fastcgipp::Transceiver::transmit().

Request a block of data for transmitting.

Returns:
A block of data with a file descriptor to transmit it out

Definition at line 237 of file transceiver.hpp.

References frames, and pRead.

Referenced by Fastcgipp::Transceiver::transmit().

Request a write block in the buffer.

Parameters:
[in]sizeRequested size of write block
Returns:
Block of writable memory. Size may be less than requested

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.

Parameters:
[in]sizeAmount of bytes to secure
[in]idAssociated complete ID (contains file descriptor)
[in]killBoolean 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().


Member Data Documentation

A list of chunks. Can contain from 2-infinity.

Definition at line 175 of file transceiver.hpp.

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().

Queue of frames waiting to be transmitted.

Definition at line 155 of file transceiver.hpp.

Referenced by requestRead().

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.

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 freeFd().

Current read spot in the buffer.

Definition at line 180 of file transceiver.hpp.

Referenced by empty(), 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(), and requestWrite().


The documentation for this class was generated from the following files: