19 #ifndef SCHEDULER_QUEUE_H 20 #define SCHEDULER_QUEUE_H 27 template <
class T, u
int8_t NMEMB>
29 static_assert(NMEMB && !(NMEMB & (NMEMB - 1)),
"Queue::NMEMB should be power of 2");
45 __attribute__((always_inline))
47 return ((NMEMB + m_put - m_get) & MASK);
55 __attribute__((always_inline))
57 return ((NMEMB - m_put + m_get - 1) & MASK);
67 unsigned int next = (m_put + 1) & MASK;
68 m_buffer[next] = *data;
80 unsigned int next = (m_put + 1) & MASK;
81 memcpy_P(&m_buffer[next], data,
sizeof(T));
93 unsigned int next = (m_get + 1) & MASK;
95 *data = m_buffer[next];
99 static const unsigned int MASK = (NMEMB - 1);
100 volatile unsigned int m_put;
101 volatile unsigned int m_get;
unsigned int available() const
void push_P(const T *data)
unsigned int room() const