gem5
|
Circular buffer backed by a vector. More...
#include <circlebuf.hh>
Public Types | |
typedef T | value_type |
Public Member Functions | |
CircleBuf (size_t size) | |
bool | empty () const |
Is the buffer empty? More... | |
size_t | capacity () const |
Return the maximum number of elements that can be stored in the buffer at any one time. More... | |
size_t | size () const |
Return the number of elements stored in the buffer. More... | |
void | flush () |
Remove all the elements 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... | |
Protected Member Functions | |
void | normalize () |
Normalize the start and stop pointers to ensure that pointer invariants hold after updates. More... | |
Protected Attributes | |
std::vector< value_type > | buf |
size_t | _start |
size_t | _stop |
Circular buffer backed by a vector.
The data in the cricular buffer is stored in a standard vector. _start designates the first element in the buffer and _stop points to the last element + 1 (i.e., the position of the next insertion). The _stop index may be outside the range of the backing store, which means that the actual index must be calculated as _stop % capacity.
Invariants:
Definition at line 68 of file circlebuf.hh.
typedef T CircleBuf< T >::value_type |
Definition at line 71 of file circlebuf.hh.
Definition at line 74 of file circlebuf.hh.
|
inline |
Return the maximum number of elements that can be stored in the buffer at any one time.
Definition at line 83 of file circlebuf.hh.
Referenced by Fifo< uint8_t >::capacity().
|
inline |
Is the buffer empty?
Definition at line 78 of file circlebuf.hh.
Referenced by Terminal::console_in(), Terminal::dataAvailable(), Fifo< uint8_t >::empty(), and Terminal::in().
|
inline |
Remove all the elements in the buffer.
Note: This does not actually remove elements from the backing store.
Definition at line 93 of file circlebuf.hh.
Referenced by arrayParamIn(), and Fifo< uint8_t >::flush().
|
inlineprotected |
Normalize the start and stop pointers to ensure that pointer invariants hold after updates.
Definition at line 186 of file circlebuf.hh.
Referenced by CircleBuf< char >::read(), and CircleBuf< char >::write().
|
inline |
Copy buffer contents without advancing the read pointer.
out | Output iterator/pointer |
len | Number of elements to copy |
Definition at line 105 of file circlebuf.hh.
Referenced by Terminal::accept(), arrayParamOut(), main(), CircleBuf< char >::peek(), Fifo< uint8_t >::peek(), and CircleBuf< char >::read().
|
inline |
Copy buffer contents without advancing the read pointer.
out | Output iterator/pointer |
offset | Offset into the ring buffer |
len | Number of elements to copy |
Definition at line 117 of file circlebuf.hh.
|
inline |
Copy buffer contents and advance the read pointer.
out | Output iterator/pointer |
len | Number of elements to read |
Definition at line 143 of file circlebuf.hh.
Referenced by Terminal::in(), main(), and Fifo< uint8_t >::read().
|
inline |
Return the number of elements stored in the buffer.
Definition at line 85 of file circlebuf.hh.
Referenced by Terminal::accept(), arrayParamOut(), main(), CircleBuf< char >::peek(), Fifo< uint8_t >::size(), and CircleBuf< char >::write().
|
inline |
Add elements to the end of the ring buffers and advance.
in | Input iterator/pointer |
len | Number of elements to read |
Definition at line 157 of file circlebuf.hh.
Referenced by arrayParamIn(), Terminal::data(), main(), Terminal::out(), and Fifo< uint8_t >::write().
|
protected |
Definition at line 199 of file circlebuf.hh.
Referenced by CircleBuf< char >::empty(), CircleBuf< char >::flush(), CircleBuf< char >::normalize(), CircleBuf< char >::peek(), CircleBuf< char >::read(), CircleBuf< char >::size(), and CircleBuf< char >::write().
|
protected |
Definition at line 200 of file circlebuf.hh.
Referenced by CircleBuf< char >::empty(), CircleBuf< char >::flush(), CircleBuf< char >::normalize(), CircleBuf< char >::size(), and CircleBuf< char >::write().
|
protected |
Definition at line 198 of file circlebuf.hh.
Referenced by CircleBuf< char >::capacity(), CircleBuf< char >::normalize(), CircleBuf< char >::peek(), and CircleBuf< char >::write().