◐ Shell
clean mode source ↗

std::thread::get_id - cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

std::thread::id get_id() const;

(desde C++11)

Retorna um valor de std::thread::id identificar o segmento associado com *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.

Parâmetros

(Nenhum)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

um valor do tipo std::thread::id identificar o segmento associado com *this. Se não existir um segmento associado, std::thread::id padrão construído é retornado.

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.

Exceções

Exemplo

#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();
}

Potencial saída:

t1's id: 0x35a7210f
t2's id: 0x35a311c4

Veja também

representa o id de um segmento

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.


(public class membro) [edit]

verifica se o segmento está acopláveis, ou seja, potencialmente executado no contexto paralelo

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.


(função pública membro) [edit]