From 6f4f91fa16e69b584ade9b82345f34322b52e5d4 Mon Sep 17 00:00:00 2001 From: Dominik Charousset Date: Wed, 23 Jun 2021 11:11:18 +0200 Subject: [PATCH] Remove unnecessary base class --- libcaf_core/caf/flow/subscription.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libcaf_core/caf/flow/subscription.hpp b/libcaf_core/caf/flow/subscription.hpp index f7e9173db0..c584f43d5d 100644 --- a/libcaf_core/caf/flow/subscription.hpp +++ b/libcaf_core/caf/flow/subscription.hpp @@ -13,8 +13,10 @@ namespace caf::flow { /// Controls the flow of items from publishers to subscribers. -class CAF_CORE_EXPORT subscription : public ref_counted { +class CAF_CORE_EXPORT subscription { public: + // -- nested types ----------------------------------------------------------- + /// Internal impl of a `disposable`. class impl : public virtual ref_counted { public: @@ -28,6 +30,8 @@ class CAF_CORE_EXPORT subscription : public ref_counted { virtual void request(size_t n) = 0; }; + // -- constructors, destructors, and assignment operators -------------------- + explicit subscription(intrusive_ptr pimpl) noexcept : pimpl_(std::move(pimpl)) { // nop @@ -44,6 +48,8 @@ class CAF_CORE_EXPORT subscription : public ref_counted { subscription& operator=(subscription&&) noexcept = default; subscription& operator=(const subscription&) noexcept = default; + // -- demand signaling ------------------------------------------------------- + /// @copydoc impl::cancel void cancel() { if (pimpl_) { @@ -58,6 +64,8 @@ class CAF_CORE_EXPORT subscription : public ref_counted { pimpl_->request(n); } + // -- properties ------------------------------------------------------------- + bool valid() const noexcept { return pimpl_ != nullptr; } @@ -70,11 +78,11 @@ class CAF_CORE_EXPORT subscription : public ref_counted { return !valid(); } - impl* ptr() { + impl* ptr() noexcept { return pimpl_.get(); } - const impl* ptr() const { + const impl* ptr() const noexcept { return pimpl_.get(); } @@ -82,7 +90,9 @@ class CAF_CORE_EXPORT subscription : public ref_counted { return std::move(pimpl_); } - void swap(subscription& other) { + // -- swapping --------------------------------------------------------------- + + void swap(subscription& other) noexcept { pimpl_.swap(other.pimpl_); }