Phosphor
phosphor::RingTraceBuffer Class Reference
Inheritance diagram for phosphor::RingTraceBuffer:
phosphor::TraceBuffer

Public Member Functions

 RingTraceBuffer (size_t generation_, size_t buffer_size_)
 
TraceChunkgetChunk () override
 
void returnChunk (TraceChunk &chunk) override
 
bool isFull () const override
 
void getStats (StatsCallback &addStats) const override
 
size_t getGeneration () const override
 
const TraceChunkoperator[] (const int index) const override
 
size_t chunk_count () const override
 
chunk_iterator chunk_begin () const override
 
chunk_iterator chunk_end () const override
 
event_iterator begin () const override
 
event_iterator end () const override
 
- Public Member Functions inherited from phosphor::TraceBuffer
virtual ~TraceBuffer ()=default
 
chunk_iterable chunks () const
 

Protected Attributes

std::atomic< size_t > actual_count
 
RelaxedAtomic< size_t > on_loan
 
gsl_p::dyn_array< TraceChunkbuffer
 
dvyukov::mpmc_bounded_queue< TraceChunk * > return_queue
 
size_t generation
 

Additional Inherited Members

- Public Types inherited from phosphor::TraceBuffer
using event_iterator = gsl_p::multidimensional_iterator< chunk_iterator >
 

Detailed Description

TraceBuffer implementation that stores events in a fixed-size vector of unique pointers to BufferChunks.

Member Function Documentation

event_iterator phosphor::RingTraceBuffer::begin ( ) const
inlineoverridevirtual
Returns
A const iterator to the first event of the TraceBuffer

Implements phosphor::TraceBuffer.

chunk_iterator phosphor::RingTraceBuffer::chunk_begin ( ) const
inlineoverridevirtual
Returns
A const iterator to the first chunk of the TraceBuffer

Implements phosphor::TraceBuffer.

size_t phosphor::RingTraceBuffer::chunk_count ( ) const
inlineoverridevirtual

Used for determining the number of chunks in the buffer

Returns
Number of chunks currently in the buffer

Implements phosphor::TraceBuffer.

chunk_iterator phosphor::RingTraceBuffer::chunk_end ( ) const
inlineoverridevirtual
Returns
A const iterator to after the last chunk of the TraceBuffer

Implements phosphor::TraceBuffer.

event_iterator phosphor::RingTraceBuffer::end ( ) const
inlineoverridevirtual
Returns
A const iterator to after the last event of the TraceBuffer

Implements phosphor::TraceBuffer.

TraceChunk* phosphor::RingTraceBuffer::getChunk ( )
inlineoverridevirtual

Used for getting a TraceChunk to add events to

Returns
A pointer to a TraceChunk to insert events into or nullptr if the buffer is full.

Implements phosphor::TraceBuffer.

size_t phosphor::RingTraceBuffer::getGeneration ( ) const
inlineoverridevirtual
Returns
The generation number of the TraceBuffer

Implements phosphor::TraceBuffer.

void phosphor::RingTraceBuffer::getStats ( StatsCallback addStats) const
inlineoverridevirtual

Callback for retrieving stats from the Buffer implementation

Implementations MUST supply the following stats as minimum:

  • buffer_name <cstring_span>: Textual representation of buffer type
  • buffer_is_full <bool>: True if the buffer is full
  • buffer_chunk_count <size_t>: Chunks that are returned or loaned
  • buffer_loaned_chunks <size_t>: Currently loaned chunks
  • buffer_total_loaned <size_t>: Count of all chunks ever loaned
  • buffer_size <size_t>: Max number of chunks that fit in the buffer
  • buffer_generation <size_t>: Generation number of the buffer

On a non-rotating buffer, if buffer_chunk_count is equal to buffer-size then that must suggest the buffer is full and there are no more chunks to be loaned. On a rotating buffer it suggests that chunks are being reused.

Buffer implementations may include other relevant stats but end-users SHOULD NOT assume the existence of those stats.

Implements phosphor::TraceBuffer.

bool phosphor::RingTraceBuffer::isFull ( ) const
inlineoverridevirtual

Determine if there are no remaining chunks left to be used

Returns
true if there are no chunks left or false otherwise

Implements phosphor::TraceBuffer.

const TraceChunk& phosphor::RingTraceBuffer::operator[] ( const int  index) const
inlineoverridevirtual

Used for accessing TraceChunks in the buffer

Valid indexes are from 0 to count(). There is no bounds checking.

Returns
A const reference to a TraceEvent in the chunk that can be used to review the event data
Exceptions
std::logic_errorif chunks are currently loaned out to chunk tenants.

Implements phosphor::TraceBuffer.

void phosphor::RingTraceBuffer::returnChunk ( TraceChunk chunk)
inlineoverridevirtual

Used for returning a TraceChunk once full

For some buffer implementations this may be a no-op but for others which might reuse chunks this can be used to only reuse chunks that have been finished with.

Parameters
chunkThe chunk to be returned

Implements phosphor::TraceBuffer.


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