gem5  v21.1.0.2
Public Types | Public Member Functions | Private Attributes | List of all members
gem5::CircleBuf< T > Class Template Reference

Circular buffer backed by a vector. More...

#include <circlebuf.hh>

Public Types

using value_type = T
 

Public Member Functions

 CircleBuf (size_t size)
 
bool empty () const
 
size_t size () const
 
size_t capacity () const
 
void flush ()
 Throw away any data in the buffer. More...
 
template<class OutputIterator >
void peek (OutputIterator out, size_t len) const
 Copy buffer contents without advancing the read pointer. More...
 
template<class OutputIterator >
void peek (OutputIterator out, off_t offset, size_t len) const
 Copy buffer contents without advancing the read pointer. More...
 
template<class OutputIterator >
void read (OutputIterator out, size_t len)
 Copy buffer contents and advance the read pointer. More...
 
template<class InputIterator >
void write (InputIterator in, size_t len)
 Add elements to the end of the ring buffers and advance. More...
 

Private Attributes

std::vector< T > buffer
 
size_t start = 0
 
size_t used = 0
 
size_t maxSize
 

Detailed Description

template<typename T>
class gem5::CircleBuf< T >

Circular buffer backed by a vector.

The data in the cricular buffer is stored in a standard vector.

Definition at line 58 of file circlebuf.hh.

Member Typedef Documentation

◆ value_type

template<typename T >
using gem5::CircleBuf< T >::value_type = T

Definition at line 67 of file circlebuf.hh.

Constructor & Destructor Documentation

◆ CircleBuf()

template<typename T >
gem5::CircleBuf< T >::CircleBuf ( size_t  size)
inlineexplicit

Definition at line 69 of file circlebuf.hh.

Member Function Documentation

◆ capacity()

template<typename T >
size_t gem5::CircleBuf< T >::capacity ( ) const
inline

Definition at line 73 of file circlebuf.hh.

Referenced by gem5::Fifo< uint8_t >::capacity().

◆ empty()

template<typename T >
bool gem5::CircleBuf< T >::empty ( ) const
inline

◆ flush()

template<typename T >
void gem5::CircleBuf< T >::flush ( )
inline

Throw away any data in the buffer.

Definition at line 79 of file circlebuf.hh.

Referenced by gem5::arrayParamIn(), gem5::Fifo< uint8_t >::flush(), and gem5::CircleBuf< char >::write().

◆ peek() [1/2]

template<typename T >
template<class OutputIterator >
void gem5::CircleBuf< T >::peek ( OutputIterator  out,
off_t  offset,
size_t  len 
) const
inline

Copy buffer contents without advancing the read pointer.

Parameters
outOutput iterator/pointer
offsetOffset into the ring buffer
lenNumber of elements to copy

Definition at line 107 of file circlebuf.hh.

◆ peek() [2/2]

template<typename T >
template<class OutputIterator >
void gem5::CircleBuf< T >::peek ( OutputIterator  out,
size_t  len 
) const
inline

Copy buffer contents without advancing the read pointer.

Parameters
outOutput iterator/pointer
lenNumber of elements to copy

Definition at line 93 of file circlebuf.hh.

Referenced by gem5::Terminal::accept(), gem5::arrayParamOut(), gem5::CircleBuf< char >::peek(), gem5::Fifo< uint8_t >::peek(), gem5::CircleBuf< char >::read(), and TEST().

◆ read()

template<typename T >
template<class OutputIterator >
void gem5::CircleBuf< T >::read ( OutputIterator  out,
size_t  len 
)
inline

Copy buffer contents and advance the read pointer.

Parameters
outOutput iterator/pointer
lenNumber of elements to read

Definition at line 140 of file circlebuf.hh.

Referenced by gem5::Fifo< uint8_t >::read(), gem5::Terminal::readData(), and TEST().

◆ size()

template<typename T >
size_t gem5::CircleBuf< T >::size ( ) const
inline

◆ write()

template<typename T >
template<class InputIterator >
void gem5::CircleBuf< T >::write ( InputIterator  in,
size_t  len 
)
inline

Add elements to the end of the ring buffers and advance.

Writes which would exceed the capacity of the queue fill the avaialble space, and then continue overwriting the head of the queue. The head advances as if that data had been read out.

Parameters
inInput iterator/pointer
lenNumber of elements to read

Definition at line 158 of file circlebuf.hh.

Referenced by gem5::arrayParamIn(), gem5::Terminal::data(), TEST(), gem5::Fifo< uint8_t >::write(), and gem5::Terminal::writeData().

Member Data Documentation

◆ buffer

template<typename T >
std::vector<T> gem5::CircleBuf< T >::buffer
private

Definition at line 61 of file circlebuf.hh.

Referenced by gem5::CircleBuf< char >::peek(), and gem5::CircleBuf< char >::write().

◆ maxSize

template<typename T >
size_t gem5::CircleBuf< T >::maxSize
private

◆ start

template<typename T >
size_t gem5::CircleBuf< T >::start = 0
private

◆ used

template<typename T >
size_t gem5::CircleBuf< T >::used = 0
private

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

Generated on Tue Sep 21 2021 12:27:23 for gem5 by doxygen 1.8.17