|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Modifiers | ||||
stop_source::request_stop | ||||
| Observers | ||||
| Non-member functions | ||||
| Helper tags | ||||
bool request_stop()noexcept; | (since C++20) | |
Issues a stop request to the stop-state, if thestop_source object has a stop-state and it has not yet already had stop requested.
The determination is made atomically, and if stop was requested, the stop-state is atomically updated to avoid race conditions, such that:
stop_tokens andstop_sources of the same stop-state;stop_source objects, and only one will actually perform the stop request.However, see the Notes section.
Contents |
(none)
true if thestop_source object has a stop-state and this invocation made a stop request, otherwisefalse.
stop_possible() isfalse orstop_requested() istrue.
If therequest_stop() does issue a stop request (i.e., returnstrue), then anystop_callbacks registered for the same associated stop-state will be invoked synchronously, on the same threadrequest_stop() is issued on. If an invocation of a callback exits via an exception,std::terminate is called.
If thestop_source object has a stop-state but a stop request has already been made, this function returnsfalse. However there is no guarantee that anotherstop_source object which has just (successfully) requested stop is not still in the middle of invoking astop_callback function.
If therequest_stop() does issue a stop request (i.e., returnstrue), then all condition variables of base typestd::condition_variable_any registered with an interruptible wait forstop_tokens associated with thestop_source's stop-state will be notified.
| This section is incomplete Reason: no example |