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

32 lines
1.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.

[stoptoken.general]
# 32 Concurrency support library [[thread]](./#thread)
## 32.3 Stop tokens [[thread.stoptoken]](thread.stoptoken#stoptoken.general)
### 32.3.4 Class stop_token [[stoptoken]](stoptoken#general)
#### 32.3.4.1 General [stoptoken.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L826)
The class stop_token models the concept [stoppable_token](stoptoken.concepts#concept:stoppable_token "32.3.3Stop token concepts[stoptoken.concepts]")[.](#1.sentence-1)
It shares ownership of its stop state, if any,
with its associated stop_source object ([[stopsource]](stopsource "32.3.5Class stop_­source")) and
any stop_token objects to which it compares equal[.](#1.sentence-2)
namespace std {class stop_token {public:template<class CallbackFn>using callback_type = stop_callback<CallbackFn>;
stop_token() noexcept = default; // [[stoptoken.mem]](stoptoken.mem "32.3.4.2Member functions"), member functionsvoid swap(stop_token&) noexcept; bool stop_requested() const noexcept; bool stop_possible() const noexcept; bool operator==(const stop_token& rhs) noexcept = default; private: shared_ptr<*unspecified*> *stop-state*; // *exposition only*};}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L856)
*stop-state* refers to the stop_token's associated stop state[.](#2.sentence-1)
A stop_token object is disengaged when *stop-state* is empty[.](#2.sentence-2)