On this page
std::stop_callback<Callback>::stop_callback
|
(1) | (since C++20) |
|
(2) | (since C++20) |
|
(3) | (since C++20) |
|
(4) | (since C++20) |
Constructs a new stop_callback
object, saving and registering the cb
callback function into the given std::stop_token
's associated stop-state, for later invocation if stop is requested on the associated std::stop_source
.
stop_callback
for the given st
std::stop_token
(copied), with the given invocable callback function cb
.
stop_callback
for the given st
std::stop_token
(moved), with the given invocable callback function cb
.
Both constructors participate overload resolution only if Callback
and C
satisfy constructible_from
of std::constructible_from<Callback, C>
. If Callback
and C
satisfy the concept but fail to satisfy its semantic requirement, the behavior is undefined.
Parameters
st | - | a std::stop_token object to register this stop_callback object with |
cb | - | the type to invoke if stop is requested |
Exceptions
noexcept
specification:
noexcept(std::is_nothrow_constructible_v<Callback, C>)
stop_callback
object.
Notes
If st.stop_requested() == true
for the passed-in std::stop_token
, then the callback function is invoked in the current thread before the constructor returns.
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/thread/stop_callback/stop_callback