7 #ifndef ZPP_INCLUDE_ZPP_FUTEX_HPP
8 #define ZPP_INCLUDE_ZPP_FUTEX_HPP
10 #ifdef CONFIG_USERSPACE
12 #include <zephyr/kernel.h>
13 #include <zephyr/sys/__assert.h>
22 template<
typename T_Futex>
45 [[nodiscard]]
bool wait(
int expected) noexcept
61 [[nodiscard]]
bool try_wait(
int expected) noexcept
78 template<
class T_Rep,
class T_Period>
80 try_wait_for(
int expected,
const std::chrono::duration<T_Rep, T_Period>& timeout) noexcept
82 using namespace std::chrono;
181 __ASSERT_NO_MSG(m_futex_ptr !=
nullptr);
190 template<
typename T_Futex>
192 : m_futex_ptr(f.native_handle())
194 __ASSERT_NO_MSG(m_futex_ptr !=
nullptr);
208 __ASSERT_NO_MSG(m_futex_ptr !=
nullptr);
220 template<
typename T_Futex>
224 __ASSERT_NO_MSG(m_futex_ptr !=
nullptr);
bool try_wait(int expected) noexcept
Try wait for the futex.
bool wait(int expected) noexcept
Wait for the futex.
void wake_all() noexcept
Wakeup all waiting threads.
bool try_wait_for(int expected, const std::chrono::duration< T_Rep, T_Period > &timeout) noexcept
Wait for the futex.
futex_base & operator=(futex_base &&)=delete
auto native_handle() const noexcept -> native_const_pointer
get the native zephyr futex handle.
struct k_futex native_type
auto native_handle() noexcept -> native_pointer
get the native zephyr futex handle.
futex_base(futex_base &&)=delete
constexpr futex_base() noexcept
Default constructor.
futex_base(const futex_base &)=delete
native_type * native_pointer
native_type const * native_const_pointer
void wake_one() noexcept
Wakeup one waiting thread.
futex_base & operator=(const futex_base &)=delete
A futex class referencing another futex object.
constexpr auto native_handle() noexcept -> native_pointer
get the native zephyr futex handle.
constexpr futex_ref & operator=(T_Futex &f) noexcept
copy operator
constexpr auto native_handle() const noexcept -> native_const_pointer
get the native zephyr futex handle.
constexpr futex_ref(native_pointer f) noexcept
Construct a futex using a native k_futex*.
constexpr futex_ref & operator=(native_pointer f) noexcept
copy operator
constexpr futex_ref(T_Futex &f) noexcept
Construct a futex using another futex object.
constexpr auto native_handle() const noexcept -> native_const_pointer
get the native zephyr futex handle.
futex & operator=(futex &&)=delete
futex & operator=(const futex &)=delete
futex(const futex &)=delete
constexpr auto native_handle() noexcept -> native_pointer
get the native zephyr futex handle.
constexpr k_timeout_t to_timeout(const std::chrono::duration< T_Rep, T_Period > &d) noexcept
convert a duration to tick