56concept ThreadEntry = std::convertible_to<F, void (*)(
void *)>;
72static_assert(OVE_ERR_NOT_REGISTERED == -1,
"OVE_ERR_NOT_REGISTERED drifted");
73static_assert(OVE_ERR_INVALID_PARAM == -2,
"OVE_ERR_INVALID_PARAM drifted");
74static_assert(OVE_ERR_NO_MEMORY == -3,
"OVE_ERR_NO_MEMORY drifted");
75static_assert(OVE_ERR_TIMEOUT == -4,
"OVE_ERR_TIMEOUT drifted");
76static_assert(OVE_ERR_NOT_SUPPORTED == -5,
"OVE_ERR_NOT_SUPPORTED drifted");
77static_assert(OVE_ERR_QUEUE_FULL == -6,
"OVE_ERR_QUEUE_FULL drifted");
78static_assert(OVE_ERR_ML_FAILED == -7,
"OVE_ERR_ML_FAILED drifted");
79static_assert(OVE_ERR_NET_REFUSED == -8,
"OVE_ERR_NET_REFUSED drifted");
80static_assert(OVE_ERR_NET_UNREACHABLE == -9,
"OVE_ERR_NET_UNREACHABLE drifted");
81static_assert(OVE_ERR_NET_ADDR_IN_USE == -10,
"OVE_ERR_NET_ADDR_IN_USE drifted");
82static_assert(OVE_ERR_NET_RESET == -11,
"OVE_ERR_NET_RESET drifted");
83static_assert(OVE_ERR_NET_DNS_FAIL == -12,
"OVE_ERR_NET_DNS_FAIL drifted");
84static_assert(OVE_ERR_NET_CLOSED == -13,
"OVE_ERR_NET_CLOSED drifted");
85static_assert(OVE_ERR_BUS_NACK == -14,
"OVE_ERR_BUS_NACK drifted");
86static_assert(OVE_ERR_BUS_BUSY == -15,
"OVE_ERR_BUS_BUSY drifted");
87static_assert(OVE_ERR_BUS_ERROR == -16,
"OVE_ERR_BUS_ERROR drifted");
88static_assert(OVE_ERR_QUEUE_EMPTY == -17,
"OVE_ERR_QUEUE_EMPTY drifted");
89static_assert(OVE_ERR_WOULD_BLOCK == -18,
"OVE_ERR_WOULD_BLOCK drifted");
90static_assert(OVE_ERR_EOF == -19,
"OVE_ERR_EOF drifted");
91static_assert(OVE_ERR_INVAL == -20,
"OVE_ERR_INVAL drifted");
92static_assert(OVE_ERR_NOT_FOUND == -21,
"OVE_ERR_NOT_FOUND drifted");
119inline constexpr std::chrono::nanoseconds
wait_forever = std::chrono::nanoseconds::max();
128template <
typename Rep,
typename Period>
129inline constexpr uint64_t
to_timeout_ns(std::chrono::duration<Rep, Period> d)
noexcept
131 const auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(d);
134 if (ns == std::chrono::nanoseconds::max())
135 return OVE_WAIT_FOREVER;
136 return static_cast<uint64_t
>(ns.count());
156 using duration = std::chrono::nanoseconds;
157 using rep = duration::rep;
158 using period = duration::period;
159 using time_point = std::chrono::time_point<steady_clock>;
160 static constexpr bool is_steady =
true;
162 static time_point now()
noexcept
164 return time_point(duration(ove_time_now_steady_ns()));
178 const auto since_epoch = tp.time_since_epoch();
179 if (since_epoch == std::chrono::nanoseconds::max())
180 return OVE_WAIT_FOREVER;
181 if (since_epoch.count() < 0)
183 return static_cast<uint64_t
>(since_epoch.count());
Concept satisfied by any callable convertible to void(*)(void*).
Definition types.hpp:56
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:20
constexpr uint64_t to_timeout_ns(std::chrono::duration< Rep, Period > d) noexcept
Convert a chrono duration to uint64_t nanoseconds for the C API.
Definition types.hpp:129
constexpr uint64_t to_deadline_ns(steady_clock::time_point tp) noexcept
Convert an ove::steady_clock::time_point to uint64_t nanoseconds for the substrate's _until APIs.
Definition types.hpp:176
constexpr std::chrono::nanoseconds wait_forever
Sentinel duration meaning "block indefinitely".
Definition types.hpp:119
Steady-clock wrapping the substrate's monotonic time source.
Definition types.hpp:155