Added 'poke' and 'clear' methods to fifo template

This commit is contained in:
Joakim Larsson Edstrom 2016-11-04 14:13:00 +01:00
parent d9f7237a7a
commit f1a1b77595

View File

@ -428,7 +428,7 @@ public:
fifo()
: std::array<T, N>()
, m_head(this->begin())
, m_tail(this->end())
, m_tail(this->begin())
, m_empty(true)
{
static_assert(0U < N, "FIFO must have at least one element");
@ -513,11 +513,28 @@ public:
return result;
}
void poke(T &v)
{
*m_tail = v;
}
void poke(T &&v)
{
*m_tail = std::move(v);
}
T const &peek() const
{
return *m_head;
}
void clear() const
{
m_head = m_tail = this->begin();
m_empty = true;
return *m_head;
}
private:
typename fifo::iterator m_head, m_tail;
bool m_empty;