std::thread::joinable
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. |
| bool joinable(); |
(desde C++11) | |
Comprueba si el objeto hilo identifica un subproceso activo de la ejecución. En concreto, los rendimientos true si get_id() != std::thread::id() .
Original:
Checks if the thread object identifies an active thread of execution. Specifically, returns true if get_id() != std::thread::id().
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.
Contenido |
[editar] Parámetros
(Ninguno)
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.
[editar] Valor de retorno
true si el objeto hilo identifica un subproceso activo de la ejecución, false lo contrario
Original:
true if the thread object identifies an active thread of execution, false otherwise
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.
[editar] Excepciones
[editar] Ejemplo
#include <iostream> #include <thread> #include <chrono> void foo() { std::this_thread::sleep_for(std::chrono::seconds(1)); } int main() { std::thread t; std::cout << "before starting, joinable: " << t.joinable() << '\n'; t = std::thread(foo); std::cout << "after starting, joinable: " << t.joinable() << '\n'; t.join(); }
Salida:
before starting, joinable: 0 after starting, joinable: 1
[editar] Ver también
| devuelve el id del hilo (función miembro público) | |
| espera a que el hilo termine su ejecución (función miembro público) | |
| desvincula el objeto del hilo en ejecución, ya no se puede hacer join y se puede destruir libremente (función miembro público) |

