Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petiaccja committed Dec 1, 2023
1 parent 6e191db commit 70f3755
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions include/async++/promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions include/async++/sleep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace impl_sleep {
using clock_type = std::chrono::steady_clock;

struct awaitable : basic_awaitable<void> {
awaitable(clock_type::time_point time) noexcept;
explicit awaitable(clock_type::time_point time) noexcept;

bool await_ready() const noexcept;
template <std::convertible_to<const resumable_promise&> Promise>
Expand All @@ -41,16 +41,16 @@ namespace impl_sleep {


template <class Rep, class Period>
auto sleep_for(std::chrono::duration<Rep, Period> duration) -> impl_sleep::awaitable {
auto sleep_for(std::chrono::duration<Rep, Period> duration) {
using impl_sleep::clock_type;
return { clock_type::now() + duration };
return impl_sleep::awaitable{ clock_type::now() + duration };
}


template <class Clock, class Dur>
auto sleep_until(std::chrono::time_point<Clock, Dur> time_point) -> impl_sleep::awaitable {
auto sleep_until(std::chrono::time_point<Clock, Dur> time_point) {
using impl_sleep::clock_type;
return { std::chrono::clock_cast<clock_type>(time_point) };
return impl_sleep::awaitable{ std::chrono::clock_cast<clock_type>(time_point) };
}

} // namespace asyncpp

0 comments on commit 70f3755

Please sign in to comment.