7 #ifndef ZPP_INCLUDE_ZPP_FIFO_HPP
8 #define ZPP_INCLUDE_ZPP_FIFO_HPP
10 #include <zephyr/kernel.h>
11 #include <zephyr/sys/__assert.h>
15 #include <type_traits>
26 template<
template<
typename>
typename T_BaseFifoType,
typename T_BaseItemType>
42 static_assert(std::is_standard_layout_v<item_type>);
43 static_assert(std::is_same_v<
void*, decltype(item_type::fifo_reserved)>);
44 static_assert(offsetof(
item_type, fifo_reserved) == 0);
54 return static_cast<T_BaseFifoType<item_type>*
>(
this)->
native_handle();
64 return static_cast<const T_BaseFifoType<item_type>*
>(
this)->
native_handle();
116 template <
class T_Rep,
class T_Period>
120 using namespace std::chrono;
124 duration_cast<milliseconds>(timeout).count()));
174 template<
typename T_ItemType>
186 k_fifo_init(&m_fifo);
220 template<
typename T_ItemType>
237 __ASSERT_NO_MSG(m_fifo_ptr !=
nullptr);
247 template<
template<
class>
class T_Fifo>
248 constexpr
explicit fifo_ref(T_Fifo<T_ItemType>& f) noexcept
249 : m_fifo_ptr(f.native_handle())
251 __ASSERT_NO_MSG(m_fifo_ptr !=
nullptr);
266 __ASSERT_NO_MSG(m_fifo_ptr !=
nullptr);
279 template<
template<
class>
class T_Fifo>
283 __ASSERT_NO_MSG(m_fifo_ptr !=
nullptr);
fifo_base(fifo_base &&)=delete
constexpr auto native_handle() noexcept -> native_pointer
get the Zephyr native fifo handle
fifo_base() noexcept
default constructor, can only be called from derived types
constexpr auto native_handle() const noexcept -> native_const_pointer
get the Zephyr native fifo handle
item_pointer try_pop_front() noexcept
try to pop item from the fifo without waiting
fifo_base(const fifo_base &)=delete
fifo_base & operator=(const fifo_base &)=delete
item_type const * item_const_pointer
item_pointer pop_front() noexcept
pop item from fifo waiting for ever
native_type * native_pointer
item_pointer try_pop_front_for(const std::chrono::duration< T_Rep, T_Period > &timeout) noexcept
try to pop item from the fifo waiting a certain amount of time
struct k_fifo native_type
void cancel_wait() noexcept
force a waiting thread to return with a timeout error
item_pointer front() noexcept
get item at the front without removing it from the fifo
void push_back(item_pointer item) noexcept
push an item on the back of the fifo
item_pointer back() noexcept
get item at the back without removing it from the fifo
bool empty() noexcept
check if the fifo is empty
native_type const * native_const_pointer
fifo_base & operator=(fifo_base &&)=delete
fifo that references a k_fifo object
constexpr fifo_ref & operator=(const T_Fifo< T_ItemType > &f) noexcept
Reference another fifo object.
constexpr auto native_handle() const noexcept -> native_const_pointer
get the Zephyr native fifo handle
constexpr fifo_ref & operator=(native_pointer f) noexcept
Reference another fifo object.
constexpr auto native_handle() noexcept -> native_pointer
get the Zephyr native fifo handle
constexpr fifo_ref(native_pointer f) noexcept
wrap k_fifo
constexpr fifo_ref(T_Fifo< T_ItemType > &f) noexcept
Reference another fifo object.
fifo that manages a k_fifo object
fifo & operator=(const fifo &)=delete
fifo(const fifo &)=delete
fifo & operator=(fifo &&)=delete
fifo() noexcept
create new fifo
constexpr auto native_handle() const noexcept -> native_const_pointer
get the Zephyr native fifo handle
constexpr auto native_handle() noexcept -> native_pointer
get the Zephyr native fifo handle