34 template <
class T, u
int8_t NMEMB>
36 static_assert(NMEMB && !(NMEMB & (NMEMB - 1)),
"NMEMB should be power of 2");
52 __attribute__((always_inline))
54 return ((NMEMB + m_put - m_get) & MASK);
62 __attribute__((always_inline))
64 return ((NMEMB - m_put + m_get - 1) & MASK);
111 static const uint8_t MASK = (NMEMB - 1);
112 volatile uint8_t m_put;
113 volatile uint8_t m_get;
117 template <
class T, u
int8_t NMEMB>
122 uint8_t next = (m_put + 1) & MASK;
123 if (
UNLIKELY(next == m_get))
return (
false);
124 m_buffer[next] = *data;
130 template <
class T, u
int8_t NMEMB>
135 uint8_t next = (m_put + 1) & MASK;
136 if (
UNLIKELY(next == m_get))
return (
false);
137 memcpy_P(&m_buffer[next], data,
sizeof(T));
143 template <
class T, u
int8_t NMEMB>
148 if (
UNLIKELY(m_get == m_put))
return (
false);
149 uint8_t next = (m_get + 1) & MASK;
151 *data = m_buffer[next];
156 template <
class T, u
int8_t NMEMB>
bool enqueue_P(const T *data)
#define static_assert(condition, message)
uint8_t available() const