• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bemanproject / net / 17516328292

11 Aug 2025 06:06PM UTC coverage: 3.39% (-0.7%) from 4.082%
17516328292

push

github

web-flow
Merge pull request #34 from bemanproject/taps-initial

Taps initial

0 of 115 new or added lines in 11 files covered. (0.0%)

28 existing lines in 5 files now uncovered.

24 of 708 relevant lines covered (3.39%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/beman/net/detail/repeat_effect_until.hpp
1
// include/beman/net/detail/repeat_effect_until.hpp                   -*-C++-*-
2
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3

4
#ifndef INCLUDED_INCLUDE_BEMAN_NET_DETAIL_REPEAT_EFFECT_UNTIL
5
#define INCLUDED_INCLUDE_BEMAN_NET_DETAIL_REPEAT_EFFECT_UNTIL
6

7
#include <beman/execution/execution.hpp>
8
#include <optional>
9
#include <type_traits>
10
#include <utility>
11

12
// ----------------------------------------------------------------------------
13

14
namespace beman::net::detail {
15
struct repeat_effect_until_t : beman::execution::sender_adaptor_closure<repeat_effect_until_t> {
16
    template <beman::execution::sender Upstream, beman::execution::sender Body, typename Predicate>
NEW
17
    auto operator()(Upstream&& upstream, Body&& body, Predicate&& predicate) const {
×
18
        return sender<std::remove_cvref_t<Upstream>, std::remove_cvref_t<Body>, std::remove_cvref_t<Predicate>>{
NEW
19
            std::forward<Upstream>(upstream), std::forward<Body>(body), std::forward<Predicate>(predicate)};
×
20
    }
21

22
    template <beman::execution::sender Upstream,
23
              beman::execution::sender Body,
24
              typename Predicate,
25
              beman::execution::receiver Receiver>
26
    struct state {
27
        struct receiver {
28
            using receiver_concept = beman::execution::receiver_t;
29
            state* _state;
30
            auto   get_env() const noexcept -> beman::execution::env_of_t<Receiver>;
31
            auto   set_value() && noexcept -> void;
32
            template <typename Error>
33
            auto set_error(Error&& e) && noexcept -> void;
34
            auto set_stopped() && noexcept -> void;
35
        };
36
        using operation_state_concept = beman::execution::operation_state_t;
37
        using upstream_state          = beman::execution::connect_result_t<Upstream, receiver>;
38
        using body_state              = beman::execution::connect_result_t<Body, receiver>;
39
        struct connector {
40
            template <beman::execution::sender Sndr, beman::execution::receiver Rcvr>
NEW
41
            connector(Sndr&& sndr, Rcvr&& rcvr)
×
NEW
42
                : _state(beman::execution::connect(std::forward<Sndr>(sndr), std::forward<Rcvr>(rcvr))) {}
×
43
            connector(connector&&) = delete;
44
            body_state _state;
45
        };
46

47
        Body                     _body;
48
        Predicate                _predicate;
49
        Receiver                 _receiver;
50
        upstream_state           _up_state;
51
        std::optional<connector> _body_state{};
52

53
        template <beman::execution::sender Up,
54
                  beman::execution::sender By,
55
                  typename Pred,
56
                  beman::execution::receiver Rcvr>
NEW
57
        state(Up&& up, By&& by, Pred&& pred, Rcvr&& rcvr) noexcept
×
NEW
58
            : _body(std::forward<By>(by)),
×
NEW
59
              _predicate(std::forward<Pred>(pred)),
×
NEW
60
              _receiver(std::forward<Rcvr>(rcvr)),
×
NEW
61
              _up_state(beman::execution::connect(std::forward<Upstream>(up), receiver{this})) {}
×
NEW
62
        auto start() & noexcept -> void { beman::execution::start(_up_state); }
×
NEW
63
        auto run_next() & noexcept -> void {
×
NEW
64
            this->_body_state.reset();
×
NEW
65
            if (this->_predicate()) {
×
NEW
66
                beman::execution::set_value(std::move(this->_receiver));
×
67
            } else {
NEW
68
                this->_body_state.emplace(std::forward<Body>(this->_body), receiver{this});
×
NEW
69
                beman::execution::start(this->_body_state->_state);
×
70
            }
NEW
71
        }
×
72
    };
73
    template <beman::execution::sender Upstream, beman::execution::sender Body, typename Predicate>
74
    struct sender {
75
        using sender_concept = beman::execution::sender_t;
76
        using completion_signatures =
77
            beman::execution::completion_signatures<beman::execution::set_value_t(),
78
                                                    //-dk:TODO add error types of upstream and body
79
                                                    //-dk:TODO add stopped only if upstream or body can be stopped
80
                                                    beman::execution::set_stopped_t()>;
81

82
        Upstream  upstream;
83
        Body      body;
84
        Predicate predicate;
85

86
        template <beman::execution::receiver Receiver>
NEW
87
        auto connect(Receiver&& receiver) {
×
NEW
88
            return state<Upstream, Body, Predicate, std::remove_cvref_t<Receiver>>{std::move(this->upstream),
×
NEW
89
                                                                                   std::move(this->body),
×
NEW
90
                                                                                   std::move(this->predicate),
×
NEW
91
                                                                                   std::forward<Receiver>(receiver)};
×
92
        }
93
    };
94
};
95
} // namespace beman::net::detail
96

97
namespace beman::net {
98
using repeat_effect_until_t = beman::net::detail::repeat_effect_until_t;
99
inline constexpr repeat_effect_until_t repeat_effect_until{};
100
} // namespace beman::net
101

102
// ----------------------------------------------------------------------------
103

104
template <beman::execution::sender Upstream,
105
          beman::execution::sender Body,
106
          typename Predicate,
107
          beman::execution::receiver Receiver>
NEW
108
auto beman::net::detail::repeat_effect_until_t::state<Upstream, Body, Predicate, Receiver>::receiver::get_env()
×
109
    const noexcept -> beman::execution::env_of_t<Receiver> {
NEW
110
    return beman::execution::get_env(this->_state->_receiver);
×
111
}
112
template <beman::execution::sender Upstream,
113
          beman::execution::sender Body,
114
          typename Predicate,
115
          beman::execution::receiver Receiver>
NEW
116
auto beman::net::detail::repeat_effect_until_t::state<Upstream, Body, Predicate, Receiver>::receiver::
×
117
    set_value() && noexcept -> void {
NEW
118
    this->_state->run_next();
×
NEW
119
}
×
120
template <beman::execution::sender Upstream,
121
          beman::execution::sender Body,
122
          typename Predicate,
123
          beman::execution::receiver Receiver>
124
template <typename Error>
NEW
125
auto beman::net::detail::repeat_effect_until_t::state<Upstream, Body, Predicate, Receiver>::receiver::set_error(
×
126
    Error&& e) && noexcept -> void {
NEW
127
    beman::execution::set_error(std::move(this->_state->_receiver), std::forward<Error>(e));
×
NEW
128
}
×
129
template <beman::execution::sender Upstream,
130
          beman::execution::sender Body,
131
          typename Predicate,
132
          beman::execution::receiver Receiver>
133
auto beman::net::detail::repeat_effect_until_t::state<Upstream, Body, Predicate, Receiver>::receiver::
134
    set_stopped() && noexcept -> void {
135
    beman::execution::set_stopped(std::move(this->_state->_receiver));
136
}
137

138
// ----------------------------------------------------------------------------
139

140
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc