From e62fc51052dadb0690d9bb87d4b6c85d1bc2f086 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 4 Jul 2022 18:22:22 +0300 Subject: [PATCH] Reimplement async::future::ready without a wait --- libs/async/include/psemek/async/future.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/async/include/psemek/async/future.hpp b/libs/async/include/psemek/async/future.hpp index ecefbcea..7a281526 100644 --- a/libs/async/include/psemek/async/future.hpp +++ b/libs/async/include/psemek/async/future.hpp @@ -158,7 +158,9 @@ namespace psemek::async bool ready() const { - return wait_for(std::chrono::seconds{0}); + if (!state_) throw empty_future_error{}; + std::unique_lock lock(state_->value_mutex); + return has_value_unsafe(); } template