diff --git a/include/seastar/core/coroutine.hh b/include/seastar/core/coroutine.hh index 2a011c16d80..1f8edb21e14 100644 --- a/include/seastar/core/coroutine.hh +++ b/include/seastar/core/coroutine.hh @@ -133,33 +133,8 @@ public: }; }; -template -struct awaiter { - seastar::future _future; -public: - explicit awaiter(seastar::future&& f) noexcept : _future(std::move(f)) { } - - awaiter(const awaiter&) = delete; - awaiter(awaiter&&) = delete; - - bool await_ready() const noexcept { - return _future.available() && (!CheckPreempt || !need_preempt()); - } - - template - void await_suspend(std::coroutine_handle hndl) noexcept { - if (!CheckPreempt || !_future.available()) { - _future.set_coroutine(hndl.promise()); - } else { - schedule(&hndl.promise()); - } - } - - std::tuple await_resume() { return _future.get(); } -}; - template -struct awaiter { +struct awaiter { seastar::future _future; public: explicit awaiter(seastar::future&& f) noexcept : _future(std::move(f)) { } @@ -184,7 +159,7 @@ public: }; template -struct awaiter { +struct awaiter { seastar::future<> _future; public: explicit awaiter(seastar::future<>&& f) noexcept : _future(std::move(f)) { } @@ -212,9 +187,9 @@ public: SEASTAR_MODULE_EXPORT_BEGIN -template -auto operator co_await(future f) noexcept { - return internal::awaiter(std::move(f)); +template +auto operator co_await(future f) noexcept { + return internal::awaiter(std::move(f)); } namespace coroutine { @@ -223,15 +198,9 @@ namespace coroutine { /// If constructed from a future, co_await-ing it will bypass /// checking if the task quota is depleted, which means that /// a ready future will be handled immediately. -template struct [[nodiscard]] without_preemption_check : public seastar::future { - explicit without_preemption_check(seastar::future&& f) noexcept : seastar::future(std::move(f)) {} -}; -template struct [[nodiscard]] without_preemption_check : public seastar::future { +template struct [[nodiscard]] without_preemption_check : public seastar::future { explicit without_preemption_check(seastar::future&& f) noexcept : seastar::future(std::move(f)) {} }; -template<> struct [[nodiscard]] without_preemption_check<> : public seastar::future<> { - explicit without_preemption_check(seastar::future<>&& f) noexcept : seastar::future<>(std::move(f)) {} -}; /// Make a lambda coroutine safe for use in an outer coroutine with /// functions that accept continuations. @@ -272,9 +241,9 @@ public: /// Wait for a future without a preemption check /// /// \param f a \c future<> wrapped with \c without_preemption_check -template -auto operator co_await(coroutine::without_preemption_check f) noexcept { - return internal::awaiter(std::move(f)); +template +auto operator co_await(coroutine::without_preemption_check f) noexcept { + return internal::awaiter(std::move(f)); } SEASTAR_MODULE_EXPORT_END @@ -285,8 +254,8 @@ SEASTAR_MODULE_EXPORT_END namespace std { SEASTAR_MODULE_EXPORT -template -class coroutine_traits, Args...> : public seastar::internal::coroutine_traits_base { +template +class coroutine_traits, Args...> : public seastar::internal::coroutine_traits_base { }; } // std