OpenSDN source code
|
#include <TBufferTransports.h>
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... | |
![]() | |
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) |
![]() | |
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) |
![]() | |
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 () |
![]() | |
TVirtualTransport () | |
TVirtualTransport (Arg_ const &arg) | |
TVirtualTransport (Arg1_ const &a1, Arg2_ const &a2) | |
![]() | |
TTransportDefaults () | |
![]() | |
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... | |
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.
|
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.
|
inlineprotectedvirtual |
Definition at line 170 of file TBufferTransports.h.
|
inline |
Fast-path borrow. A lot like the fast-path read.
Definition at line 107 of file TBufferTransports.h.
|
protectedpure virtual |
Slow path borrow.
POSTCONDITION: return == NULL || rBound_ - rBase_ >= *len
Implemented in contrail::sandesh::transport::TMemoryBuffer.
|
inline |
Consume doesn't require a slow path.
Definition at line 120 of file TBufferTransports.h.
|
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.
|
inline |
Shortcutted version of readAll.
Definition at line 75 of file TBufferTransports.h.
|
protectedpure virtual |
Slow path read.
Implemented in contrail::sandesh::transport::TMemoryBuffer.
|
inline |
Convenience mutator for setting the read buffer.
Definition at line 130 of file TBufferTransports.h.
|
inline |
Convenience mutator for setting the write buffer.
Definition at line 136 of file TBufferTransports.h.
|
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.
|
protectedpure virtual |
Slow path write.
Implemented in contrail::sandesh::transport::TMemoryBuffer.
|
protected |
Reads begin here.
Definition at line 173 of file TBufferTransports.h.
|
protected |
Reads may extend to just before here.
Definition at line 175 of file TBufferTransports.h.
|
protected |
Writes begin here.
Definition at line 178 of file TBufferTransports.h.
|
protected |
Writes may extend to just before here.
Definition at line 180 of file TBufferTransports.h.