std::thread:: ~thread
From cppreference.net
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
~thread
(
)
;
|
(depuis C++11) | |
Détruit l'objet thread.
Si * this a un thread associé ( joinable ( ) == true ), std:: terminate ( ) est appelée.
Notes
Un objet thread n'a pas de thread associé (et peut être détruit sans risque) après
Exemple
Exécuter ce code
#include <thread> using namespace std::chrono_literals; int main() { auto bleah = std::thread{[]{ std::this_thread::sleep_for(13ms); }}; } // ~thread appelle std::terminate()
Sortie possible :
terminate called without an active exception
Voir aussi
|
si le thread est joignable, alors un arrêt est demandé et le thread se joint
(fonction membre publique de
std::jthread
)
|