Files
cppdraft_translate/cppdraft/stopcallback/general.md
2025-10-25 03:02:53 +03:00

41 lines
2.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[stopcallback.general]
# 32 Concurrency support library [[thread]](./#thread)
## 32.3 Stop tokens [[thread.stoptoken]](thread.stoptoken#stopcallback.general)
### 32.3.6 Class template stop_callback [[stopcallback]](stopcallback#general)
#### 32.3.6.1 General [stopcallback.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1039)
[🔗](#lib:stop_callback)
namespace std {template<class CallbackFn>class stop_callback {public:using callback_type = CallbackFn; // [[stopcallback.cons]](stopcallback.cons "32.3.6.2Constructors and destructor"), constructors and destructortemplate<class Initializer>explicit stop_callback(const stop_token& st, Initializer&& init)noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>); template<class Initializer>explicit stop_callback(stop_token&& st, Initializer&& init)noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>); ~stop_callback();
stop_callback(const stop_callback&) = delete;
stop_callback(stop_callback&&) = delete;
stop_callback& operator=(const stop_callback&) = delete;
stop_callback& operator=(stop_callback&&) = delete; private: CallbackFn *callback-fn*; // *exposition only*}; template<class CallbackFn> stop_callback(stop_token, CallbackFn) -> stop_callback<CallbackFn>;}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1071)
*Mandates*: stop_callback is instantiated with an argument for the
template parameter CallbackFn that satisfies both [invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]") and [destructible](concept.destructible#concept:destructible "18.4.10Concept destructible[concept.destructible]")[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1078)
*Remarks*: For a type Initializer,
if[*stoppable-callback-for*](stoptoken.concepts#concept:stoppable-callback-for "32.3.3Stop token concepts[stoptoken.concepts]")<CallbackFn, stop_token, Initializer> is satisfied, then[*stoppable-callback-for*](stoptoken.concepts#concept:stoppable-callback-for "32.3.3Stop token concepts[stoptoken.concepts]")<CallbackFn, stop_token, Initializer> is modeled[.](#3.sentence-1)
The exposition-only *callback-fn* member is
the associated callback function ([[stoptoken.concepts]](stoptoken.concepts "32.3.3Stop token concepts")) ofstop_callback<
CallbackFn> objects[.](#3.sentence-2)