Files
2025-10-25 03:02:53 +03:00

87 lines
3.0 KiB
Markdown
Raw Permalink 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.inplace]
# 32 Concurrency support library [[thread]](./#thread)
## 32.3 Stop tokens [[thread.stoptoken]](thread.stoptoken#stoptoken.inplace)
### 32.3.8 Class inplace_stop_token [stoptoken.inplace]
#### [32.3.8.1](#general) General [[stoptoken.inplace.general]](stoptoken.inplace.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1158)
The class inplace_stop_token models
the concept [stoppable_token](stoptoken.concepts#concept:stoppable_token "32.3.3Stop token concepts[stoptoken.concepts]")[.](#general-1.sentence-1)
It references the stop state of
its associated inplace_stop_source object ([[stopsource.inplace]](stopsource.inplace "32.3.9Class inplace_­stop_­source")),
if any[.](#general-1.sentence-2)
namespace std {class inplace_stop_token {public:template<class CallbackFn>using callback_type = inplace_stop_callback<CallbackFn>;
inplace_stop_token() = default; bool operator==(const inplace_stop_token&) const = default; // [[stoptoken.inplace.mem]](#mem "32.3.8.2Member functions"), member functionsbool stop_requested() const noexcept; bool stop_possible() const noexcept; void swap(inplace_stop_token&) noexcept; private:const inplace_stop_source* *stop-source* = nullptr; // *exposition only*};}
#### [32.3.8.2](#mem) Member functions [[stoptoken.inplace.mem]](stoptoken.inplace.mem)
[🔗](#mem-itemdecl:1)
`void swap(inplace_stop_token& rhs) noexcept;
`
[1](#mem-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1192)
*Effects*: Exchanges the values of *stop-source* and rhs.*stop-source*[.](#mem-1.sentence-1)
[🔗](#mem-itemdecl:2)
`bool stop_requested() const noexcept;
`
[2](#mem-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1202)
*Effects*: Equivalent to:return *stop-source* != nullptr && *stop-source*->stop_requested();
[3](#mem-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1209)
[*Note [1](#mem-note-1)*:
As specified in [[basic.life]](basic.life "6.8.4Lifetime"),
the behavior of stop_requested is undefined
unless the call strongly happens before the start of
the destructor of the associated inplace_stop_source object, if any[.](#mem-3.sentence-1)
— *end note*]
[🔗](#mem-itemdecl:3)
`stop_possible() const noexcept;
`
[4](#mem-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1223)
*Returns*: *stop-source* != nullptr[.](#mem-4.sentence-1)
[5](#mem-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1227)
[*Note [2](#mem-note-2)*:
As specified in [[basic.stc.general]](basic.stc.general "6.8.6.1General"),
the behavior of stop_possible is implementation-defined
unless the call strongly happens before
the end of the storage duration of
the associated inplace_stop_source object, if any[.](#mem-5.sentence-1)
— *end note*]