gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::CircularQueue< T > Class Template Reference

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 >, referenceoperator[] (const Idx &index)
 
template<typename Idx >
std::enable_if_t< std::is_integral_v< Idx >, const_referenceoperator[] (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
 

Detailed Description

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

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.

Template Parameters
TType of the elements in the queue

Definition at line 69 of file circular_queue.hh.

Member Typedef Documentation

◆ const_reference

template<typename T >
using gem5::CircularQueue< T >::const_reference = typename std::vector<T>::const_reference
protected

Definition at line 75 of file circular_queue.hh.

◆ reference

template<typename T >
using gem5::CircularQueue< T >::reference = typename std::vector<T>::reference
protected

Definition at line 74 of file circular_queue.hh.

Member Function Documentation

◆ getIterator()

template<typename T >
iterator gem5::CircularQueue< T >::getIterator ( size_t idx)
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().

◆ isValidIdx()

template<typename T >
bool gem5::CircularQueue< T >::isValidIdx ( size_t idx) const
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().

◆ operator[]()

template<typename T >
template<typename Idx >
std::enable_if_t< std::is_integral_v< Idx >, const_reference > gem5::CircularQueue< T >::operator[] ( const Idx & index) const
inline

Member Data Documentation

◆ _capacity

◆ _head

◆ _size

◆ data

template<typename T >
std::vector<T> gem5::CircularQueue< T >::data
protected

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

Generated on Tue Jun 18 2024 16:24:10 for gem5 by doxygen 1.11.0