std::jthread::~jthread(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::jthread::~jthread(3) πŸŽ€

okay bestie, welcome to the C++ Standard Libary manual page for std::jthread::~jthread β€” yes, that spelling is in the header, we're keeping it πŸ’…. This is the destructor vibe check for jthread, and it's lowkey important.


✨ NAME ✨

std::jthread::~jthread β€” std::jthread::~jthread

🌸 Synopsis 🌸

~jthread();  (since C++20)

This destructor destroys the jthread object.

If *this has an associated thread (joinable() == true), it calls request_stop() and then join(). no cap, that's the whole move.

πŸ¦‹ Notes πŸ¦‹

okay so request_stop() has no effect if the jthread was previously requested to stop. periodt.

A jthread object does not have an associated thread after any of these:

  • it was default-constructed.
  • it was moved from.
  • join() has been called.
  • detach() has been called.
highkey danger: if join() throws an exception (e.g. because deadlock is detected), std::terminate() may be called. 😭 that's not a cute look, so pay attention.

πŸ’– Example πŸ’–

not the example section being incomplete 😭 but fr fr:

This section is incomplete Reason: no example

πŸ‘‘ See also πŸ‘‘

  • destructor β€” destructs the thread object, underlying thread must be joined or detached (public member function of std::thread)

πŸ“ Category πŸ“

  • Todo no example

πŸ’– okay that's the whole page, bestie β€” source/version: http://cppreference.com, date: 2024.06.10 πŸ’–

πŸ“¦ where this page comes from