OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
contrail::sandesh::transport::TBufferBase Class Referenceabstract

#include <TBufferTransports.h>

Inheritance diagram for contrail::sandesh::transport::TBufferBase:
Collaboration diagram for contrail::sandesh::transport::TBufferBase:

Public Member Functions

int32_t read (uint8_t *buf, uint32_t len)
 
int32_t readAll (uint8_t *buf, uint32_t len)
 
int write (const uint8_t *buf, uint32_t len)
 
const uint8_t * borrow (uint8_t *buf, uint32_t *len)
 
void consume (uint32_t len)
 
void setReadBuffer (uint8_t *buf, uint32_t len)
 Convenience mutator for setting the read buffer. More...
 
void setWriteBuffer (uint8_t *buf, uint32_t len)
 Convenience mutator for setting the write buffer. More...
 
- Public Member Functions inherited from contrail::sandesh::transport::TVirtualTransport< TBufferBase >
virtual int32_t read_virt (uint8_t *buf, uint32_t len)
 
virtual int32_t readAll_virt (uint8_t *buf, uint32_t len)
 
virtual int write_virt (const uint8_t *buf, uint32_t len)
 
virtual const uint8_t * borrow_virt (uint8_t *buf, uint32_t *len)
 
virtual void consume_virt (uint32_t len)
 
uint32_t readAll (uint8_t *buf, uint32_t len)
 
- Public Member Functions inherited from contrail::sandesh::transport::TTransportDefaults
uint32_t read (uint8_t *buf, uint32_t len)
 
uint32_t readAll (uint8_t *buf, uint32_t len)
 
int write (const uint8_t *buf, uint32_t len)
 
const uint8_t * borrow (uint8_t *buf, uint32_t *len)
 
void consume (uint32_t len)
 
- Public Member Functions inherited from contrail::sandesh::transport::TTransport
virtual ~TTransport ()
 
virtual bool isOpen ()
 
virtual bool peek ()
 
virtual void open ()
 
virtual void close ()
 
int32_t read (uint8_t *buf, uint32_t len)
 
int32_t readAll (uint8_t *buf, uint32_t len)
 
virtual uint32_t readEnd ()
 
int write (const uint8_t *buf, uint32_t len)
 
virtual uint32_t writeEnd ()
 
virtual void flush ()
 
const uint8_t * borrow (uint8_t *buf, uint32_t *len)
 
void consume (uint32_t len)
 

Protected Member Functions

virtual uint32_t readSlow (uint8_t *buf, uint32_t len)=0
 Slow path read. More...
 
virtual int writeSlow (const uint8_t *buf, uint32_t len)=0
 Slow path write. More...
 
virtual const uint8_t * borrowSlow (uint8_t *buf, uint32_t *len)=0
 
 TBufferBase ()
 
virtual ~TBufferBase ()
 
- Protected Member Functions inherited from contrail::sandesh::transport::TVirtualTransport< TBufferBase >
 TVirtualTransport ()
 
 TVirtualTransport (Arg_ const &arg)
 
 TVirtualTransport (Arg1_ const &a1, Arg2_ const &a2)
 
- Protected Member Functions inherited from contrail::sandesh::transport::TTransportDefaults
 TTransportDefaults ()
 
- Protected Member Functions inherited from contrail::sandesh::transport::TTransport
 TTransport ()
 

Protected Attributes

uint8_t * rBase_
 Reads begin here. More...
 
uint8_t * rBound_
 Reads may extend to just before here. More...
 
uint8_t * wBase_
 Writes begin here. More...
 
uint8_t * wBound_
 Writes may extend to just before here. More...
 

Detailed Description

Base class for all transports that use read/write buffers for performance.

TBufferBase is designed to implement the fast-path "memcpy" style operations that work in the common case. It does so with small and (eventually) nonvirtual, inlinable methods. TBufferBase is an abstract class. Subclasses are expected to define the "slow path" operations that have to be done when the buffers are full or empty.

Definition at line 50 of file TBufferTransports.h.

Constructor & Destructor Documentation

contrail::sandesh::transport::TBufferBase::TBufferBase ( )
inlineprotected

Trivial constructor.

Initialize pointers safely. Constructing is not a very performance-sensitive operation, so it is okay to just leave it to the concrete class to set up pointers correctly.

Definition at line 163 of file TBufferTransports.h.

virtual contrail::sandesh::transport::TBufferBase::~TBufferBase ( )
inlineprotectedvirtual

Definition at line 170 of file TBufferTransports.h.

Member Function Documentation

const uint8_t* contrail::sandesh::transport::TBufferBase::borrow ( uint8_t *  buf,
uint32_t *  len 
)
inline

Fast-path borrow. A lot like the fast-path read.

Definition at line 107 of file TBufferTransports.h.

Here is the call graph for this function:

virtual const uint8_t* contrail::sandesh::transport::TBufferBase::borrowSlow ( uint8_t *  buf,
uint32_t *  len 
)
protectedpure virtual

Slow path borrow.

POSTCONDITION: return == NULL || rBound_ - rBase_ >= *len

Implemented in contrail::sandesh::transport::TMemoryBuffer.

void contrail::sandesh::transport::TBufferBase::consume ( uint32_t  len)
inline

Consume doesn't require a slow path.

Definition at line 120 of file TBufferTransports.h.

int32_t contrail::sandesh::transport::TBufferBase::read ( uint8_t *  buf,
uint32_t  len 
)
inline

Fast-path read.

When we have enough data buffered to fulfill the read, we can satisfy it with a single memcpy, then adjust our internal pointers. If the buffer is empty, we call out to our slow path, implemented by a subclass. This method is meant to eventually be nonvirtual and inlinable.

Definition at line 62 of file TBufferTransports.h.

Here is the call graph for this function:

int32_t contrail::sandesh::transport::TBufferBase::readAll ( uint8_t *  buf,
uint32_t  len 
)
inline

Shortcutted version of readAll.

Definition at line 75 of file TBufferTransports.h.

Here is the call graph for this function:

virtual uint32_t contrail::sandesh::transport::TBufferBase::readSlow ( uint8_t *  buf,
uint32_t  len 
)
protectedpure virtual

Slow path read.

Implemented in contrail::sandesh::transport::TMemoryBuffer.

void contrail::sandesh::transport::TBufferBase::setReadBuffer ( uint8_t *  buf,
uint32_t  len 
)
inline

Convenience mutator for setting the read buffer.

Definition at line 130 of file TBufferTransports.h.

void contrail::sandesh::transport::TBufferBase::setWriteBuffer ( uint8_t *  buf,
uint32_t  len 
)
inline

Convenience mutator for setting the write buffer.

Definition at line 136 of file TBufferTransports.h.

int contrail::sandesh::transport::TBufferBase::write ( const uint8_t *  buf,
uint32_t  len 
)
inline

Fast-path write.

When we have enough empty space in our buffer to accomodate the write, we can satisfy it with a single memcpy, then adjust our internal pointers. If the buffer is full, we call out to our slow path, implemented by a subclass. This method is meant to eventually be nonvirtual and inlinable. Returns 0 on success, non-zero otherwise.

Definition at line 94 of file TBufferTransports.h.

Here is the call graph for this function:

virtual int contrail::sandesh::transport::TBufferBase::writeSlow ( const uint8_t *  buf,
uint32_t  len 
)
protectedpure virtual

Slow path write.

Implemented in contrail::sandesh::transport::TMemoryBuffer.

Member Data Documentation

uint8_t* contrail::sandesh::transport::TBufferBase::rBase_
protected

Reads begin here.

Definition at line 173 of file TBufferTransports.h.

uint8_t* contrail::sandesh::transport::TBufferBase::rBound_
protected

Reads may extend to just before here.

Definition at line 175 of file TBufferTransports.h.

uint8_t* contrail::sandesh::transport::TBufferBase::wBase_
protected

Writes begin here.

Definition at line 178 of file TBufferTransports.h.

uint8_t* contrail::sandesh::transport::TBufferBase::wBound_
protected

Writes may extend to just before here.

Definition at line 180 of file TBufferTransports.h.


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