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 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 192 of file transceiver.hpp.


Member Function Documentation

bool Fastcgipp::Transceiver::Buffer::empty (  )  [inline]

Test of the buffer is empty.

Returns:
true if 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.

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

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

Definition at line 235 of file transceiver.hpp.

References frames, and pRead.

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

Block Fastcgipp::Transceiver::Buffer::requestWrite ( size_t  size  )  [inline]

Request a write block in the buffer.

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

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.

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


Member Data Documentation

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

Definition at line 175 of file transceiver.hpp.

Referenced by freeRead(), and secureWrite().

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

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

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


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

Generated on Thu Dec 11 01:47:28 2008 for fastcgi++ by  doxygen 1.5.7.1