std::stop_callback<Callback>::stop_callback
From cppreference.com
< cpp | thread | stop callback
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Concurrency support library
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
(C++26)
(C++20)
(C++26)
(C++20)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++11)
(C++11)
(C++17)
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++20)(C++20)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++26)
(C++26)
(C++26)
(C++11)
(C++20)
(C++11)
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
(C++11)
(C++11)
(C++11)(deprecated in C++26)
(C++11)
(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++26)(C++26)
(C++26)(C++26)
(C++11)
(C++20)(C++20)
(C++20)
(C++20)
(C++11)(C++11)
(C++11)(C++11)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
template< class C >
explicit stop_callback( const std::stop_token & st, C&& cb ) noexcept(/*see below*/);
(1)
(since C++20)
explicit stop_callback( const std::stop_token & st, C&& cb ) noexcept(/*see below*/);
template< class C >
explicit stop_callback( std::stop_token && st, C&& cb ) noexcept(/*see below*/);
(2)
(since C++20)
explicit stop_callback( std::stop_token && st, C&& cb ) noexcept(/*see below*/);
stop_callback( const stop_callback& ) = delete;
(3)
(since C++20)
stop_callback( stop_callback&& ) = delete;
(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.
1) Constructs a
stop_callback
for the given st std::stop_token (copied), with the given invocable callback function cb.2) Constructs a
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.
[edit] Parameters
st
-
a std::stop_token object to register this
stop_callback
object with
cb
-
the type to invoke if stop is requested
[edit] Exceptions
1,2)
noexcept specification:
Any exception thrown by constructor-initializing the given callback into the noexcept(std::is_nothrow_constructible_v <Callback, C>)
stop_callback
object.[edit] 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.