std::thread::get_id
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> std::thread::id get_id() const; |
(depuis C++11) | |
Renvoie une valeur de
std::thread::id identifier le thread associé à *this .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.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Retourne la valeur
une valeur de type
std::thread::id identifier le thread associé à *this. S'il n'ya pas de thread associé, std::thread::id par défaut construit est retourné .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.
You can help to correct and verify the translation. Click here for instructions.
Exceptions
Exemple
#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();
}
Résultat possible :
t1's id: 0x35a7210f
t2's id: 0x35a311c4
Voir aussi
représente l'id d'un thread Original: represents the id of a thread The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe membre publique) | |
vérifie si le fil est joignable, soit potentiellement s'exécute dans un contexte parallèle Original: checks whether the thread is joinable, i.e. potentially running in parallel context The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |