Skip to content

Commit

Permalink
Remove unnecessary base class
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Jun 23, 2021
1 parent f8b923f commit 6f4f91f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions libcaf_core/caf/flow/subscription.hpp
Expand Up @@ -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:
Expand All @@ -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<impl> pimpl) noexcept
: pimpl_(std::move(pimpl)) {
// nop
Expand All @@ -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_) {
Expand All @@ -58,6 +64,8 @@ class CAF_CORE_EXPORT subscription : public ref_counted {
pimpl_->request(n);
}

// -- properties -------------------------------------------------------------

bool valid() const noexcept {
return pimpl_ != nullptr;
}
Expand All @@ -70,19 +78,21 @@ 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();
}

intrusive_ptr<impl>&& as_intrusive_ptr() && noexcept {
return std::move(pimpl_);
}

void swap(subscription& other) {
// -- swapping ---------------------------------------------------------------

void swap(subscription& other) noexcept {
pimpl_.swap(other.pimpl_);
}

Expand Down

0 comments on commit 6f4f91f

Please sign in to comment.