From 70f37553291e24f364a41eb66082a89d66d98c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Fri, 1 Dec 2023 21:52:29 +0100 Subject: [PATCH] fixes --- include/async++/promise.hpp | 14 +++++++------- include/async++/sleep.hpp | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/async++/promise.hpp b/include/async++/promise.hpp index f753cc5..590b33d 100644 --- a/include/async++/promise.hpp +++ b/include/async++/promise.hpp @@ -101,22 +101,22 @@ namespace impl { public: #ifdef ASYNCPP_BUILD_TESTS - leak_checked_promise() { num_alive.fetch_add(1, std::memory_order_relaxed); } - leak_checked_promise(const leak_checked_promise&) : leak_checked_promise() {} - leak_checked_promise(leak_checked_promise&&) : leak_checked_promise() {} - leak_checked_promise& operator=(const leak_checked_promise&) { return *this; } - leak_checked_promise& operator=(leak_checked_promise&&) { return *this; } + leak_checked_promise() noexcept { num_alive.fetch_add(1, std::memory_order_relaxed); } + leak_checked_promise(const leak_checked_promise&) noexcept { num_alive.fetch_add(1, std::memory_order_relaxed); } + leak_checked_promise(leak_checked_promise&&) noexcept = delete; + leak_checked_promise& operator=(const leak_checked_promise&) noexcept { return *this; } + leak_checked_promise& operator=(leak_checked_promise&&) noexcept = delete; ~leak_checked_promise() { num_alive.fetch_sub(1, std::memory_order_relaxed); version.fetch_add(1, std::memory_order_relaxed); } #endif - static snapshot_type snapshot() { + static snapshot_type snapshot() noexcept { return { num_alive.load(std::memory_order_relaxed), version.load(std::memory_order_relaxed) }; } - static bool check(snapshot_type s) { + static bool check(snapshot_type s) noexcept { const auto current = snapshot(); return current.first == s.first && current.second > s.second; } diff --git a/include/async++/sleep.hpp b/include/async++/sleep.hpp index 25d31d4..b216e11 100644 --- a/include/async++/sleep.hpp +++ b/include/async++/sleep.hpp @@ -15,7 +15,7 @@ namespace impl_sleep { using clock_type = std::chrono::steady_clock; struct awaitable : basic_awaitable { - awaitable(clock_type::time_point time) noexcept; + explicit awaitable(clock_type::time_point time) noexcept; bool await_ready() const noexcept; template Promise> @@ -41,16 +41,16 @@ namespace impl_sleep { template -auto sleep_for(std::chrono::duration duration) -> impl_sleep::awaitable { +auto sleep_for(std::chrono::duration duration) { using impl_sleep::clock_type; - return { clock_type::now() + duration }; + return impl_sleep::awaitable{ clock_type::now() + duration }; } template -auto sleep_until(std::chrono::time_point time_point) -> impl_sleep::awaitable { +auto sleep_until(std::chrono::time_point time_point) { using impl_sleep::clock_type; - return { std::chrono::clock_cast(time_point) }; + return impl_sleep::awaitable{ std::chrono::clock_cast(time_point) }; } } // namespace asyncpp \ No newline at end of file