sockets::DBuffer Class Reference

Dynamic buffer class. More...

#include <dbuffer.h>

Inheritance diagram for sockets::DBuffer:

sockets::Buffer List of all members.

Public Types

typedef std::list< Chunk * > chunks_list

Public Member Functions

 DBuffer (uint8_t chunkmul, size_t maxsize)
 Constructor.
virtual ~DBuffer ()
 Destructor.
virtual bool read (size_t max, char const **data, size_t *len) const
 Implements Buffer::read().
virtual bool write (char const *data, size_t len)
 Implements Buffer::write().
virtual bool erase (size_t len)
 Implements Buffer::erase().
virtual bool clear ()
 Implements Buffer::clear().
virtual bool empty () const
 Implements Buffer::empty().
virtual size_type size () const
 Implements Buffer::size().
virtual size_type max_size () const
 Implements Buffer::max_size().

Static Public Attributes

static size_t const chunk_unit = 1024
 The chunk unit.

Protected Member Functions

virtual bool read_byte (size_type pos, char *ch) const
 Implements Buffer::read_byte().

Classes

class  Chunk

Detailed Description

Dynamic buffer class.

This buffer, while still having a maximum size, allocates memory progressively by small chunks and frees them as needed so the buffer never grows bigger than needed, which makes it ideal when used with a large number of sockets.

When freeing memory chunks, the buffer may choose to "recycle" it instead, which means that they are placed in a pool for being reused by this or another buffer who need a chunk of the same size.


Constructor & Destructor Documentation

sockets::DBuffer::DBuffer uint8_t  chunkmul,
size_t  maxsize
[explicit]
 

Constructor.

Parameters:
[in] chunkmul This number, which must be between 1 and 64, is multiplied by DBuffer::chunk_unit to set the size of the memory chunks that are allocated dynamically.
[in] maxsize The maximum size of the buffer, in bytes. This is not allocated immediately; see the description of the class for more info.


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:22 2007 for Epona API by  doxygen 1.4.6