Skip to content

Commit

Permalink
fix(lazy_io): delay assertion about steady clock
Browse files Browse the repository at this point in the history
  • Loading branch information
Codesire-Deng committed Nov 22, 2023
1 parent a2dbe1e commit 45e01f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions include/co_context/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace co_context::detail {

template<typename...>
inline constexpr bool false_v = false;

template<typename T>
struct remove_rvalue_reference {
using type = T;
Expand Down
14 changes: 8 additions & 6 deletions include/co_context/lazy_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ inline namespace lazy {
inline detail::lazy_timeout timeout_at(
std::chrono::time_point<std::chrono::system_clock, Duration> time_point
) noexcept {
static_assert(
liburingcxx::is_kernel_reach(5, 15)
|| std::chrono::system_clock::is_steady,
"io_uring timeouts only use the CLOCK_MONOTONIC clock source "
"until 5.15. That means the clock must be steady."
);
if constexpr (!liburingcxx::is_kernel_reach(5, 15) && !std::chrono::system_clock::is_steady) {
static_assert(
detail::false_v<decltype(time_point)>,
"io_uring timeouts only use the CLOCK_MONOTONIC clock source "
"until 5.15. That means the clock must be steady. "
"Please consider std::chrono::steady_clock instead."
);
}
return detail::lazy_timeout{time_point};
}

Expand Down

0 comments on commit 45e01f5

Please sign in to comment.