std::thread::get_id – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
|
|
(seit C++11) | |
Gibt einen Wert von std::thread::id Identifizierung der Faden mit *this assoziiert .
Original:
Returns a value of std::thread::id identifying the thread associated with *this.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parameter
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Rückgabewert
ein Wert vom Typ std::thread::id Identifizierung der Faden mit *this verbunden. Wenn es kein Faden zugeordnet ist, wird standardmäßig gebaut std::thread::id zurückgegeben .
Original:
a value of type std::thread::id identifying the thread associated with *this. If there is no thread associated, default constructed std::thread::id is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ausnahmen
Beispiel
#include <iostream> #include <thread> #include <chrono> void foo() { std::this_thread::sleep_for(std::chrono::seconds(1)); } int main() { std::thread t1(foo); std::thread::id t1_id = t1.get_id(); std::thread t2(foo); std::thread::id t2_id = t2.get_id(); std::cout << "t1's id: " << t1_id << '\n'; std::cout << "t2's id: " << t2_id << '\n'; t1.join(); t2.join(); }
Possible output:
t1's id: 0x35a7210f t2's id: 0x35a311c4
Siehe auch
| repräsentiert die ID eines Threads (öffentlichen Member der Klasse) [edit] | |
| prüft, ob der Thread joinable ist, d.h., möglicherweise parallel läuft (öffentliche Elementfunktion) [edit] | |