87 lines
3.0 KiB
Markdown
87 lines
3.0 KiB
Markdown
[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.3 Stop 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.9 Class 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.2 Member 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.4 Lifetime"),
|
||
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.1 General"),
|
||
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*]
|