Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/thread/never stop token"

From cppreference.com
< cpp‎ | thread
m (members appearing with the class do not need to be versioned)
m (fmt a bit.)
Line 10: Line 10:
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc hitem|Type|Definition}}
 
{{dsc hitem|Type|Definition}}
{{dsc|{{c/core|callback_type<Callback>}}|{{c/core|/*callback-type*/}}<br><br>where the type is defined as:
+
{{dsc|{{c/core|callback_type<Callback>}}|{{c/core|/*callback-type*/}}<br>where the type is defined as:
{{ddcla|expos=yes|1=
+
{{ddcla|expos=yes|
 
struct /*callback-type*/
 
struct /*callback-type*/
 
{
 
{
  explicit /*callback-type*/(never_stop_token, auto&&) noexcept {}
+
    explicit /*callback-type*/( never_stop_token,
 +
                                auto&& ) noexcept {}
 
};
 
};
 
}}
 
}}

Revision as of 20:40, 1 November 2024

 
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
(C++20)
never_stop_token
(C++26)
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
Safe Reclamation
(C++26)
Hazard Pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
Memory ordering
Free functions for atomic operations
Free functions for atomic flags
 
Defined in header <stop_token>
class never_stop_token;
(since C++26)

The never_stop_token class models std::unstoppable_token that provides static information that a stop is never possible nor requested. It is the default stop token type returned by std::get_stop_token if no other associated stop token is being provided in the queryable object.

Contents

Member alias templates

Type Definition
callback_type<Callback> /*callback-type*/
where the type is defined as:
struct /*callback-type*/

{
    explicit /*callback-type*/( never_stop_token,
                                auto&& ) noexcept {}

};
(exposition only*)

Member functions

stop_requested
[static]
indicates that a stop can never be requested
(public static member function)
stop_possible
[static]
indicates that a stop is not possible
(public static member function)
operator==
compares two never_stop_token objects
(public member function)

std::never_stop_token::stop_requested

static constexpr bool stop_requested() noexcept { return false; }

Always returns false, indicating that a stop can never be requested.

std::never_stop_token::stop_possible

static constexpr bool stop_possible() noexcept { return false; }

Always returns false, indicating that a stop is not possible.

std::never_stop_token::operator==

bool operator==(const never_stop_token&) const = default;

Two never_stop_token objects always compare equal.

Example