[#BloombergLP-ball-RecordBuffer]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::RecordBuffer
:relfileprefix: ../../
:mrdocs:

Provide a protocol (or pure interface) for managing record handles (specifically instances of `bsl&colon;&colon;shared&lowbar;ptr&lt;Record&gt;`)&period;

== Synopsis

Declared in `&lt;ball&lowbar;recordbuffer&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class RecordBuffer;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/RecordBuffer/2destructor.adoc[`&#126;RecordBuffer`] [.small]#[destructor]# [.small]#[virtual]#
| Remove all record handles stored in this record buffer and destroy this record buffer&period;
| xref:BloombergLP/ball/RecordBuffer/back.adoc[`back`]  [.small]#[virtual]#
| Return a reference of the shared pointer referring to the record positioned at the back of this record buffer&period; The behavior is undefined unless this record buffer has been locked by the `beginSequence` method and `0 &lt; length()`&period;
| xref:BloombergLP/ball/RecordBuffer/beginSequence.adoc[`beginSequence`]  [.small]#[virtual]#
| _Lock_ this record buffer so that a sequence of method invocations on this record buffer can occur uninterrupted by other threads&period; The buffer will remain _locked_ until `endSequence` is called&period;
| xref:BloombergLP/ball/RecordBuffer/endSequence.adoc[`endSequence`]  [.small]#[virtual]#
| _Unlock_ this record buffer, thus allowing other threads to access it&period; The behavior is undefined unless the buffer is already _locked_ by `beginSequence` method&period;
| xref:BloombergLP/ball/RecordBuffer/front.adoc[`front`]  [.small]#[virtual]#
| Return a reference of the shared pointer referring to the record positioned at the front of this record buffer&period; The behavior is undefined unless this record buffer has been locked by the `beginSequence` method and `0 &lt; length()`&period;
| xref:BloombergLP/ball/RecordBuffer/length.adoc[`length`]  [.small]#[virtual]#
| Return the number of record handles in this record buffer&period;
| xref:BloombergLP/ball/RecordBuffer/popBack.adoc[`popBack`]  [.small]#[virtual]#
| Remove from this record buffer the record handle positioned at the back of the buffer&period; The behavior is undefined unless `0 &lt; length()`&period;
| xref:BloombergLP/ball/RecordBuffer/popFront.adoc[`popFront`]  [.small]#[virtual]#
| Remove from this record buffer the record handle positioned at the front of the buffer&period; The behavior is undefined unless `0 &lt; length()`&period;
| xref:BloombergLP/ball/RecordBuffer/pushBack.adoc[`pushBack`]  [.small]#[virtual]#
| Append the specified `handle` to the back of this record buffer&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that concrete implementations are permitted to remove records from the buffer in order to attempt to accommodate a `pushBack` request (which implies that, after a successful call to `pushBack`, `length` is not guaranteed to be more than one, and an unsuccessful call to `pushBack` is permitted to leave the buffer empty)&period;
| xref:BloombergLP/ball/RecordBuffer/pushFront.adoc[`pushFront`]  [.small]#[virtual]#
| Insert the specified `handle` at the front of this record buffer&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that concrete implementations are permitted to remove records from the buffer in order to attempt to accommodate a `pushFront` request (which implies that, after a successful call to `pushFront`, `length` is not guaranteed to be more than one, and an unsuccessful call to `pushFront` is permitted to leave the buffer empty)&period;
| xref:BloombergLP/ball/RecordBuffer/removeAll.adoc[`removeAll`]  [.small]#[virtual]#
| Remove all record handles stored in this record buffer&period; Note that `length()` is now 0&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FixedSizeRecordBuffer.adoc[`FixedSizeRecordBuffer`] 
| This class provides a concrete, thread&hyphen;safe implementation of the `RecordBuffer` protocol&period; This class is a mechanism&period; 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&period; The class is thread&hyphen;safe, except that the methods `front` and `back` must be called after locking the buffer by invoking `beginSequence`&period; In order to accommodate a `pushBack` request, the records from the front end of the buffer may be removed&period; Similarly, in order to accommodate a `pushFront` request, the records from the back end of the buffer may be removed&period; If a record can not accommodate in the buffer, it is silently (but otherwise safely) discarded&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
