Files
cppdraft_translate/cppdraft/exec/scope/counting.md
2025-10-25 03:02:53 +03:00

3.2 KiB
Raw Blame History

[exec.scope.counting]

33 Execution control library [exec]

33.14 Execution scope utilities [exec.scope]

33.14.2 Counting Scopes [exec.counting.scopes]

33.14.2.3 Counting Scope [exec.scope.counting]

🔗

namespace std::execution {class counting_scope {public:struct token {template<sender Sender>sender auto wrap(Sender&& snd) const noexcept(see below); bool try_associate() const noexcept; void disassociate() const noexcept; private: counting_scope* scope; // exposition only}; static constexpr size_t max_associations = implementation-defined;

counting_scope() noexcept; counting_scope(counting_scope&&) = delete; ~counting_scope();

token get_token() noexcept; void close() noexcept; sender auto join() noexcept; void request_stop() noexcept; private: size_t count; // exposition only**scope-state-type state; // exposition only inplace_stop_source s_source; // exposition onlybool try-associate() noexcept; // exposition onlyvoid disassociate() noexcept; // exposition onlytemplatebool start-join-sender(State& state) noexcept; // exposition only};}

1

#

counting_scope differs from simple_counting_scope by adding support for cancellation.

Unless specified below, the semantics of members of counting_scope are the same as the corresponding members of simple_counting_scope.

🔗

token get_token() noexcept;

2

#

Returns: An object t of type counting_scope::token such thatt.scope == this is true.

🔗

void request_stop() noexcept;

3

#

Effects: Equivalent to s_source.request_stop().

4

#

Remarks: Calls to request_stop do not introduce data races.

🔗

template<[sender](exec.snd.concepts#concept:sender "33.9.3Sender concepts[exec.snd.concepts]") Sender> [sender](exec.snd.concepts#concept:sender "33.9.3Sender concepts[exec.snd.concepts]") auto counting_scope::token::wrap(Sender&& snd) const noexcept(is_nothrow_constructible_v<remove_cvref_t<Sender>, Sender>);

5

#

Effects: Equivalent to:return stop-when(std::forward(snd), scope->s_source.get_token());