ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
interface_disposable.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2023 - present.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// https://www.boost.org/LICENSE_1_0.txt)
7//
8// Project home: https://github.com/victimsnino/ReactivePlusPlus
9//
10
11#pragma once
12
13#include <rpp/disposables/fwd.hpp>
14
15namespace rpp
16{
23 {
24 virtual ~interface_disposable() noexcept = default;
25
30 virtual bool is_disposed() const noexcept = 0;
31
36 void dispose() noexcept { dispose_impl(Mode::Disposing); }
37
38 template<rpp::constraint::decayed_type TStrategy>
40
41 protected:
42 enum class Mode : bool
43 {
44 Disposing = 0, // someone called "dispose" method manually
45 Destroying = 1 // called during destruction -> not needed to clear self in other disposables and etc + not allowed to call `shared_from_this`
46 };
47
48 virtual void dispose_impl(Mode mode) noexcept = 0;
49 };
50} // namespace rpp
Interface of disposable.
Definition interface_disposable.hpp:23
virtual bool is_disposed() const noexcept=0
Check if this disposable is just disposed.
void dispose() noexcept
Dispose disposable and free any underlying resources and etc.
Definition interface_disposable.hpp:36