48 lines
1.8 KiB
Markdown
48 lines
1.8 KiB
Markdown
[stopcallback.cons]
|
||
|
||
# 32 Concurrency support library [[thread]](./#thread)
|
||
|
||
## 32.3 Stop tokens [[thread.stoptoken]](thread.stoptoken#stopcallback.cons)
|
||
|
||
### 32.3.6 Class template stop_callback [[stopcallback]](stopcallback#cons)
|
||
|
||
#### 32.3.6.2 Constructors and destructor [stopcallback.cons]
|
||
|
||
[ð](#lib:stop_callback,constructor)
|
||
|
||
`template<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>);
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1103)
|
||
|
||
*Constraints*: CallbackFn and Initializer satisfy[constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_from [concept.constructible]")<CallbackFn, Initializer>[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1108)
|
||
|
||
*Effects*: Initializes *callback-fn* with std::forward<Initializer>(init) and executes a stoppable callback registration ([[stoptoken.concepts]](stoptoken.concepts "32.3.3 Stop token concepts"))[.](#2.sentence-1)
|
||
|
||
If a callback is registered with st's shared stop state,
|
||
then *this acquires shared ownership of that stop state[.](#2.sentence-2)
|
||
|
||
[ð](#lib:stop_callback,destructor)
|
||
|
||
`~stop_callback();
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L1122)
|
||
|
||
*Effects*: Executes a stoppable callback deregistration ([[stoptoken.concepts]](stoptoken.concepts "32.3.3 Stop token concepts")) and
|
||
releases ownership of the stop state, if any[.](#3.sentence-1)
|