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 only bool try-associate() noexcept; // exposition only void disassociate() noexcept; // exposition only template<class State> bool start-join-sender(State& state) noexcept; // exposition only }; }
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;
Returns: An object t of type counting_scope​::​token such that t.scope == this is true.
void request_stop() noexcept;
Effects: Equivalent to s_source.request_stop().
Remarks: Calls to request_stop do not introduce data races.
template<sender Sender> sender auto counting_scope::token::wrap(Sender&& snd) const noexcept(is_nothrow_constructible_v<remove_cvref_t<Sender>, Sender>);
Effects: Equivalent to: return stop-when(std::forward<Sender>(snd), scope->s_source.get_token());