|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
stop_callback::stop_callback | ||||
| Deduction guides |
template<class C> explicit stop_callback(conststd::stop_token& st, C&& cb)noexcept(/*see below*/); | (1) | (since C++20) |
template<class C> explicit stop_callback(std::stop_token&& st, C&& cb)noexcept(/*see below*/); | (2) | (since C++20) |
stop_callback(const stop_callback&)= delete; | (3) | (since C++20) |
stop_callback( stop_callback&&)= delete; | (4) | (since C++20) |
Constructs a newstop_callback object, saving and registering thecb callback function into the givenstd::stop_token's associated stop-state, for later invocation if stop is requested on the associatedstd::stop_source.
stop_callback for the givenststd::stop_token (copied), with the given invocable callback functioncb.stop_callback for the givenststd::stop_token (moved), with the given invocable callback functioncb.Both constructors participate overload resolution only ifCallback andC satisfyconstructible_from ofstd::constructible_from<Callback, C>. IfCallback andC satisfy the concept but fail to satisfy its semantic requirement, the behavior is undefined.
| st | - | astd::stop_token object to register thisstop_callback object with |
| cb | - | the type to invoke if stop is requested |
stop_callback object.Ifst.stop_requested()==true for the passed-instd::stop_token, then the callback function is invoked in the current thread before the constructor returns.