gem5 v24.0.0.0
|
Circular queue. More...
#include <circular_queue.hh>
Classes | |
struct | iterator |
Iterator to the circular queue. More... | |
Public Member Functions | |
template<typename Idx > | |
std::enable_if_t< std::is_integral_v< Idx >, reference > | operator[] (const Idx &index) |
template<typename Idx > | |
std::enable_if_t< std::is_integral_v< Idx >, const_reference > | operator[] (const Idx &index) const |
CircularQueue (size_t size=0) | |
void | flush () |
Remove all the elements in the queue. | |
bool | isValidIdx (size_t idx) const |
Test if the index is in the range of valid elements. | |
reference | front () |
reference | back () |
size_t | head () const |
size_t | tail () const |
size_t | capacity () const |
size_t | size () const |
void | pop_front (size_t num_elem=1) |
Circularly increase the head pointer. | |
void | pop_back () |
Circularly decrease the tail pointer. | |
void | push_back (typename std::vector< T >::value_type val) |
Pushes an element at the end of the queue. | |
void | advance_tail () |
Increases the tail by one. | |
void | advance_tail (size_t len) |
Increases the tail by a specified number of steps. | |
bool | empty () const |
Is the queue empty? | |
bool | full () const |
Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th} element, or if the head is the n^{th} element and the tail the (n-1)^{th} element. | |
iterator | begin () |
Iterators. | |
iterator | begin () const |
iterator | end () |
iterator | end () const |
iterator | getIterator (size_t idx) |
Return an iterator to an index in the queue. | |
Protected Types | |
using | reference = typename std::vector<T>::reference |
using | const_reference = typename std::vector<T>::const_reference |
Protected Attributes | |
std::vector< T > | data |
const size_t | _capacity |
size_t | _size = 0 |
size_t | _head = 1 |
Circular queue.
Circular queue implemented in a standard vector. All indices are monotonically increasing, and modulo is used at access time to alias them down to the actual storage.
The queue keeps track of two pieces of state, a head index, which is the index of the next element to come out of the queue, and a size which is how many valid elements are currently in the queue. Size can increase to, but never exceed, the capacity of the queue.
In theory the index may overflow at some point, but since it's a 64 bit value that would take a very long time.
T | Type of the elements in the queue |
Definition at line 69 of file circular_queue.hh.
|
protected |
Definition at line 75 of file circular_queue.hh.
|
protected |
Definition at line 74 of file circular_queue.hh.
|
inline |
Return an iterator to an index in the queue.
Definition at line 592 of file circular_queue.hh.
Referenced by gem5::o3::LSQUnit::insertLoad(), gem5::o3::LSQUnit::insertStore(), and gem5::prefetch::PIF::notifyRetiredInst().
|
inline |
Test if the index is in the range of valid elements.
Definition at line 433 of file circular_queue.hh.
References gem5::CircularQueue< T >::_head, and gem5::CircularQueue< T >::_size.
Referenced by gem5::CircularQueue< T >::iterator::dereferenceable().
|
inline |
Definition at line 403 of file circular_queue.hh.
References gem5::CircularQueue< T >::_capacity, gem5::CircularQueue< T >::data, and gem5::MipsISA::index.
|
protected |
Definition at line 76 of file circular_queue.hh.
Referenced by gem5::CircularQueue< T >::advance_tail(), gem5::CircularQueue< T >::capacity(), gem5::CircularQueue< T >::full(), gem5::CircularQueue< T >::operator[](), and gem5::CircularQueue< T >::operator[]().
|
protected |
Definition at line 78 of file circular_queue.hh.
Referenced by gem5::CircularQueue< T >::advance_tail(), gem5::CircularQueue< T >::advance_tail(), gem5::CircularQueue< T >::begin(), gem5::CircularQueue< T >::begin(), gem5::CircularQueue< T >::flush(), gem5::CircularQueue< T >::head(), gem5::CircularQueue< T >::isValidIdx(), gem5::CircularQueue< T >::pop_front(), and gem5::CircularQueue< T >::tail().
|
protected |
Definition at line 77 of file circular_queue.hh.
Referenced by gem5::CircularQueue< T >::advance_tail(), gem5::CircularQueue< T >::advance_tail(), gem5::CircularQueue< T >::empty(), gem5::CircularQueue< T >::flush(), gem5::CircularQueue< T >::full(), gem5::CircularQueue< T >::isValidIdx(), gem5::CircularQueue< T >::pop_back(), gem5::CircularQueue< T >::pop_front(), gem5::CircularQueue< T >::size(), and gem5::CircularQueue< T >::tail().
|
protected |
Definition at line 72 of file circular_queue.hh.
Referenced by gem5::CircularQueue< T >::operator[](), and gem5::CircularQueue< T >::operator[]().