BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::FixedSizeRecordBuffer Class Reference

#include <ball_fixedsizerecordbuffer.h>

Inheritance diagram for ball::FixedSizeRecordBuffer:
ball::RecordBuffer

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (FixedSizeRecordBuffer, bslma::UsesBslmaAllocator)
 
 FixedSizeRecordBuffer (int maxTotalSize, bslma::Allocator *basicAllocator=0)
 
 ~FixedSizeRecordBuffer () BSLS_KEYWORD_OVERRIDE
 
void beginSequence () BSLS_KEYWORD_OVERRIDE
 
void endSequence () BSLS_KEYWORD_OVERRIDE
 
void popBack () BSLS_KEYWORD_OVERRIDE
 
void popFront () BSLS_KEYWORD_OVERRIDE
 
int pushBack (const bsl::shared_ptr< Record > &handle) BSLS_KEYWORD_OVERRIDE
 
int pushFront (const bsl::shared_ptr< Record > &handle) BSLS_KEYWORD_OVERRIDE
 
void removeAll () BSLS_KEYWORD_OVERRIDE
 
const bsl::shared_ptr< Record > & back () const BSLS_KEYWORD_OVERRIDE
 
const bsl::shared_ptr< Record > & front () const BSLS_KEYWORD_OVERRIDE
 
int length () const BSLS_KEYWORD_OVERRIDE
 Return the number of record handles in this record buffer.
 
- Public Member Functions inherited from ball::RecordBuffer
virtual ~RecordBuffer ()
 

Detailed Description

This class provides a concrete, thread-safe implementation of the RecordBuffer protocol. This class is a mechanism. At any time, the sum of sizes of all records contained in a FixedSizeRecordBuffer object plus the amount of memory allocated by the FixedSizeRecordBuffer object itself is guaranteed to be less than or equal to an upper bound specified at creation. The class is thread-safe, except that the methods front and back must be called after locking the buffer by invoking beginSequence. In order to accommodate a pushBack request, the records from the front end of the buffer may be removed. Similarly, in order to accommodate a pushFront request, the records from the back end of the buffer may be removed. If a record can not accommodate in the buffer, it is silently (but otherwise safely) discarded.

See ball_fixedsizerecordbuffer

Constructor & Destructor Documentation

◆ FixedSizeRecordBuffer()

ball::FixedSizeRecordBuffer::FixedSizeRecordBuffer ( int  maxTotalSize,
bslma::Allocator basicAllocator = 0 
)
inline

Create a limited record buffer such that at any time the sum of sizes of all records contained plus the amount of memory allocated by this object is guaranteed to be less than or equal to the specified maxTotalSize. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless maxTotalSize > 0.

◆ ~FixedSizeRecordBuffer()

ball::FixedSizeRecordBuffer::~FixedSizeRecordBuffer ( )

Remove all record handles from this record buffer and destroy this record buffer.

Member Function Documentation

◆ back()

const bsl::shared_ptr< Record > & ball::FixedSizeRecordBuffer::back ( ) const
inlinevirtual

Return a reference of the shared pointer referring to the record positioned at the back end of this record buffer. The behavior is undefined unless this record buffer has been locked by the beginSequence method and unless 0 < length().

Implements ball::RecordBuffer.

◆ beginSequence()

void ball::FixedSizeRecordBuffer::beginSequence ( )
inlinevirtual

Lock this record buffer so that a sequence of method invocations on this record buffer can occur uninterrupted by other threads. The buffer will remain locked until endSequence is called. It is valid to invoke other methods on this record buffer between the calls to beginSequence and endSequence (the implementation guarantees this by employing a recursive mutex).

Implements ball::RecordBuffer.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::FixedSizeRecordBuffer::BSLMF_NESTED_TRAIT_DECLARATION ( FixedSizeRecordBuffer  ,
bslma::UsesBslmaAllocator   
)

◆ endSequence()

void ball::FixedSizeRecordBuffer::endSequence ( )
inlinevirtual

Unlock this record buffer, thus allowing other threads to access it. The behavior is undefined unless the buffer is already locked by beginSequence.

Implements ball::RecordBuffer.

◆ front()

const bsl::shared_ptr< Record > & ball::FixedSizeRecordBuffer::front ( ) const
inlinevirtual

Return a reference of the shared pointer referring to the record positioned at the front end of this record buffer. The behavior is undefined unless this record buffer has been locked by the beginSequence method and unless 0 < length().

Implements ball::RecordBuffer.

◆ length()

int ball::FixedSizeRecordBuffer::length ( ) const
inlinevirtual

Implements ball::RecordBuffer.

◆ popBack()

void ball::FixedSizeRecordBuffer::popBack ( )
virtual

Remove from this record buffer the record handle positioned at the back end of the buffer. The behavior is undefined unless 0 < length().

Implements ball::RecordBuffer.

◆ popFront()

void ball::FixedSizeRecordBuffer::popFront ( )
virtual

Remove from this record buffer the record handle positioned at the front end of the buffer. The behavior is undefined unless 0 < length().

Implements ball::RecordBuffer.

◆ pushBack()

int ball::FixedSizeRecordBuffer::pushBack ( const bsl::shared_ptr< Record > &  handle)
virtual

Push the specified handle at the back end of this record buffer. Return 0 on success, and a non-zero value otherwise. In order to accommodate a record, the records from the front end of the buffer may be removed. If a record can not be accommodated in the buffer, it is silently discarded.

Implements ball::RecordBuffer.

◆ pushFront()

int ball::FixedSizeRecordBuffer::pushFront ( const bsl::shared_ptr< Record > &  handle)
virtual

Push the specified handle at the front end of this record buffer. Return 0 on success, and a non-zero value otherwise. In order to accommodate a record, the records from the end end of the buffer may be removed. If a record can not be accommodated in the buffer, it is silently discarded.

Implements ball::RecordBuffer.

◆ removeAll()

void ball::FixedSizeRecordBuffer::removeAll ( )
inlinevirtual

Remove all record handles stored in this record buffer. Note that length() is now 0.

Implements ball::RecordBuffer.


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