ReactivePlusPlus
ReactiveX implementation for C++20
Toggle main menu visibility
Loading...
Searching...
No Matches
disposables_strategy.hpp
1
// ReactivePlusPlus library
2
//
3
// Copyright Aleksey Loginov 2022 - 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/AlexInLog/ReactivePlusPlus
9
//
10
11
#pragma once
12
13
#include <rpp/observers/details/fwd.hpp>
14
15
#include <rpp/defs.hpp>
16
#include <rpp/disposables/disposable_wrapper.hpp>
17
18
#include <atomic>
19
20
namespace
rpp::details::observers
21
{
22
template
<
typename
DisposableContainer>
23
class
local_disposables_strategy
24
{
25
public
:
26
local_disposables_strategy() =
default
;
27
local_disposables_strategy(local_disposables_strategy&& other)
noexcept
=
default
;
28
29
void
add(
const
disposable_wrapper
& d)
30
{
31
m_upstreams.push_back(d);
32
}
33
34
bool
is_disposed()
const
noexcept
35
{
36
return
m_is_disposed;
37
}
38
39
void
dispose()
const
40
{
41
m_is_disposed =
true
;
42
m_upstreams.dispose();
43
}
44
45
private
:
46
RPP_NO_UNIQUE_ADDRESS DisposableContainer m_upstreams{};
47
mutable
bool
m_is_disposed{};
48
};
49
50
struct
none_disposables_strategy
51
{
52
static
constexpr
void
add(
const
rpp::disposable_wrapper
&) { }
53
54
static
constexpr
bool
is_disposed()
noexcept
{
return
false
; }
55
56
static
constexpr
void
dispose() { }
57
};
58
59
class
boolean_disposables_strategy
60
{
61
public
:
62
static
constexpr
void
add(
const
rpp::disposable_wrapper
&) { }
63
64
bool
is_disposed()
const
noexcept
{
return
m_is_disposed; }
65
66
void
dispose()
const
{ m_is_disposed =
true
; }
67
68
private
:
69
mutable
bool
m_is_disposed{};
70
};
71
}
// namespace rpp::details::observers
rpp::details::observers::boolean_disposables_strategy
Definition
disposables_strategy.hpp:60
rpp::disposable_wrapper
disposable_wrapper_impl< interface_disposable > disposable_wrapper
Wrapper to keep "simple" disposable. Specialization of rpp::disposable_wrapper_impl.
Definition
fwd.hpp:34
rpp::details::observers::none_disposables_strategy
Definition
disposables_strategy.hpp:51
src
rpp
rpp
observers
details
disposables_strategy.hpp
Generated by
1.17.0