Standard library header <thread> (C++11)
From cppreference.net
Dieser Header ist Teil der Thread-Unterstützungsbibliothek .
Includes |
||
|
(C++20)
|
Drei-Wege-Vergleichsoperator Unterstützung | |
Namespaces |
||
this_thread
|
stellt Funktionen bereit, die auf den aktuellen Ausführungsthread zugreifen | |
Klassen |
||
|
(C++11)
|
verwaltet einen separaten Thread
(Klasse) |
|
|
(C++20)
|
std::thread
mit Unterstützung für automatisches Join und Abbruch
(Klasse) |
|
|
spezialisiert
std::hash
(Klassen-Template-Spezialisierung) |
||
Funktionen |
||
|
(C++11)
|
spezialisiert den
std::swap
Algorithmus
(Funktion) |
|
|
(entfernt in C++20)
(entfernt in C++20)
(entfernt in C++20)
(entfernt in C++20)
(entfernt in C++20)
(C++20)
|
vergleicht zwei
thread::id
Objekte
(Funktion) |
|
serialisiert ein
thread::id
Objekt
(Funktions-Template) |
||
|
Definiert im Namespace
std::this_thread
|
||
|
(C++11)
|
schlägt vor, dass die Implementierung die Ausführung von Threads neu plant
(Funktion) |
|
|
(C++11)
|
gibt die Thread-ID des aktuellen Threads zurück
(Funktion) |
|
|
(C++11)
|
stoppt die Ausführung des aktuellen Threads für eine bestimmte Zeitdauer
(Funktion) |
|
|
(C++11)
|
stoppt die Ausführung des aktuellen Threads bis zu einem bestimmten Zeitpunkt
(Funktion) |
|
Synopsis
#include <compare> namespace std { // Klasse thread class thread; void swap(thread& x, thread& y) noexcept; // Klasse jthread class jthread; // Namensraum this_thread namespace this_thread { thread::id get_id() noexcept; void yield() noexcept; template<class Clock, class Duration> void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); template<class Rep, class Period> void sleep_for(const chrono::duration<Rep, Period>& rel_time); } }
Klasse std::thread
namespace std { class thread { public: // Klasse thread::id class id; using native_handle_type = /* implementierungsdefiniert */; // Konstruktion/Kopieren/Zerstörung thread() noexcept; template<class F, class... Args> explicit thread(F&& f, Args&&... args); ~thread(); thread(const thread&) = delete; thread(thread&&) noexcept; thread& operator=(const thread&) = delete; thread& operator=(thread&&) noexcept; // Elementfunktionen void swap(thread&) noexcept; bool joinable() const noexcept; void join(); void detach(); id get_id() const noexcept; native_handle_type native_handle(); // Statische Elementfunktionen static unsigned int hardware_concurrency() noexcept; }; }
Klasse std::jthread
namespace std { class jthread { public: // Typen using id = thread::id; using native_handle_type = thread::native_handle_type; // Konstruktoren, Move- und Zuweisungsoperationen jthread() noexcept; template<class F, class... Args> explicit jthread(F&& f, Args&&... args); ~jthread(); jthread(const jthread&) = delete; jthread(jthread&&) noexcept; jthread& operator=(const jthread&) = delete; jthread& operator=(jthread&&) noexcept; // Memberfunktionen void swap(jthread&) noexcept; bool joinable() const noexcept; void join(); void detach(); id get_id() const noexcept; native_handle_type native_handle(); // Stop-Token-Behandlung stop_source get_stop_source() noexcept; stop_token get_stop_token() const noexcept; bool request_stop() noexcept; // Spezialisierte Algorithmen friend void swap(jthread& lhs, jthread& rhs) noexcept; // Statische Member static unsigned int hardware_concurrency() noexcept; private: stop_source ssource; // Nur zur Darstellung }; }
Klasse std::thread::id
namespace std { class thread::id { public: id() noexcept; }; bool operator==(thread::id x, thread::id y) noexcept; strong_ordering operator<=>(thread::id x, thread::id y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& out, thread::id id); template<class CharT> struct formatter<thread::id, CharT>; // Hash-Unterstützung template<class T> struct hash; template<> struct hash<thread::id>; }