Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
BufferBase Class Reference

Abstract base class for all Buffers. More...

#include <Buffer.hxx>

Inheritance diagram for BufferBase:
QMember Buffer< uint8_t[]> Buffer< HubContainer > Buffer< NumberDumper::Chunk > Buffer< openlcb::IncomingDatagram > Buffer< openlcb::GenMessage > Buffer< withrottle::ThrottleCommand > Buffer< T > DataBuffer

Public Member Functions

uint16_t references ()
 
void set_done (BarrierNotifiable *done)
 Specifies that a given BarrierNotifiable must be called when the Buffer is deallocated (unreffed to zero, meaning that all owners have freed it).
 
BarrierNotifiablenew_child ()
 Creates a new child notifiable of the current done notifiable.
 
size_t size ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Protected Member Functions

Poolpool ()
 Get a pointer to the pool that this buffer belongs to.
 
 BufferBase (size_t size, Pool *pool)
 Constructor.
 
 ~BufferBase ()
 Destructor.
 
 DISALLOW_COPY_AND_ASSIGN (BufferBase)
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 

Protected Attributes

Poolpool_
 Reference to the pool from whence this buffer came.
 
BarrierNotifiabledone_
 Notifiable to call when the buffer has finished processing everywhere.
 
uint16_t size_
 size of data in bytes
 
std::atomic_uint_least16_t count_
 number of references in use
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Friends

class openlcb::AsyncIfTest
 
class Pool
 Allow Pool access to our constructor.
 
class DynamicPool
 Allow DynamicPool access to our constructor.
 
class FixedPool
 Allow FixedPool access to our constructor.
 
class LimitedPool
 Allow LimitedPool access to our fields.
 
class DataBufferPool
 Allow DataBufferPool access to our fields.
 

Detailed Description

Abstract base class for all Buffers.

This class contains all shared components that are not template-dependent.

Definition at line 84 of file Buffer.hxx.

Constructor & Destructor Documentation

◆ BufferBase()

BufferBase::BufferBase ( size_t  size,
Pool pool 
)
inlineprotected

Constructor.

Initializes count to 1 and done_ to NULL.

Parameters
sizesize of buffer data
poolpool this buffer belong to

Definition at line 152 of file Buffer.hxx.

◆ ~BufferBase()

BufferBase::~BufferBase ( )
inlineprotected

Destructor.

Definition at line 163 of file Buffer.hxx.

Member Function Documentation

◆ new_child()

BarrierNotifiable * BufferBase::new_child ( )
inline

Creates a new child notifiable of the current done notifiable.

Returns
the new notifiable, or NULL if there is no current notifiable.

Definition at line 108 of file Buffer.hxx.

◆ pool()

Pool * BufferBase::pool ( )
inlineprotected

Get a pointer to the pool that this buffer belongs to.

Returns
pool that this buffer belongs to

Definition at line 130 of file Buffer.hxx.

◆ references()

uint16_t BufferBase::references ( )
inline
Returns
reference count; always >0; >1 if this Buffer is shared by multiple owners.

Definition at line 89 of file Buffer.hxx.

◆ set_done()

void BufferBase::set_done ( BarrierNotifiable done)
inline

Specifies that a given BarrierNotifiable must be called when the Buffer is deallocated (unreffed to zero, meaning that all owners have freed it).

Parameters
doneis the notifiable to call.

Definition at line 97 of file Buffer.hxx.

◆ size()

size_t BufferBase::size ( )
inline
Returns
the number of payload bytes owned by this buffer.

Definition at line 121 of file Buffer.hxx.

Friends And Related Symbol Documentation

◆ DataBufferPool

friend class DataBufferPool
friend

Allow DataBufferPool access to our fields.

Definition at line 187 of file Buffer.hxx.

◆ DynamicPool

friend class DynamicPool
friend

Allow DynamicPool access to our constructor.

Definition at line 178 of file Buffer.hxx.

◆ FixedPool

friend class FixedPool
friend

Allow FixedPool access to our constructor.

Definition at line 181 of file Buffer.hxx.

◆ LimitedPool

friend class LimitedPool
friend

Allow LimitedPool access to our fields.

Definition at line 184 of file Buffer.hxx.

◆ openlcb::AsyncIfTest

friend class openlcb::AsyncIfTest
friend

Definition at line 172 of file Buffer.hxx.

◆ Pool

friend class Pool
friend

Allow Pool access to our constructor.

Definition at line 175 of file Buffer.hxx.

Member Data Documentation

◆ count_

std::atomic_uint_least16_t BufferBase::count_
protected

number of references in use

Definition at line 146 of file Buffer.hxx.

◆ done_

BarrierNotifiable* BufferBase::done_
protected

Notifiable to call when the buffer has finished processing everywhere.

May be nullptr.

Definition at line 140 of file Buffer.hxx.

◆ pool_

Pool* BufferBase::pool_
protected

Reference to the pool from whence this buffer came.

Definition at line 136 of file Buffer.hxx.

◆ size_

uint16_t BufferBase::size_
protected

size of data in bytes

Definition at line 143 of file Buffer.hxx.


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