std::this_thread(3)

πŸ’– std::this_thread β€” the Library Functions Manual glow-up πŸ’–

okay bestie, so this is a page from the Library Functions Manual (yes, that's the manual name, we're being official about it for like two seconds) and it's all about std::this_thread, which is lowkey the most useful little namespace in the whole C++11 universe.


✨ NAME ✨

std::this_thread β€” the ISO C++ 2011 namespace for interacting with the current thread. it's giving "me, myself, and my thread" πŸ’…


🌸 SYNOPSIS 🌸

πŸ¦‹ Functions

  • thread::id get_id () noexcept β€” the unique identifier of the current thread. it's literally your thread's little name tag πŸŽ€
  • template<typename _Rep, typename _Period> void sleep_for (const chrono::duration< _Rep, _Period > &__rtime) β€” this_thread::sleep_for
  • template<typename _Clock, typename _Duration> void sleep_until (const chrono::time_point< _Clock, _Duration > &__atime) β€” this_thread::sleep_until
  • void yield () noexcept β€” allow the implementation to schedule a different thread. sharing is caring fr fr 🫢

πŸ‘‘ Detailed Description πŸ‘‘

ISO C++ 2011 namespace for interacting with the current thread. that's the whole vibe. one namespace, four functions, infinite main character energy.

C++11 30.3.2 [thread.thread.this] Namespace this_thread. (yes that's the actual standard reference, iykyk πŸ“–)


πŸ’… Function Documentation πŸ’…

⭐ thread::id std::this_thread::get_id () [inline], [noexcept]

The unique identifier of the current thread.

like a social security number but for your thread. it's how the runtime knows which one is you ✨

🌈 template<typename _Rep, typename _Period> void std::this_thread::sleep_for (const chrono::duration< _Rep, _Period > & __rtime) [inline]

this_thread::sleep_for

Referenced by sleep_until().

πŸ’œ template<typename _Clock, typename _Duration> void std::this_thread::sleep_until (const chrono::time_point< _Clock, _Duration > & __atime) [inline]

this_thread::sleep_until

References sleep_for().

πŸŽ€ void std::this_thread::yield () [inline], [noexcept]

Allow the implementation to schedule a different thread.

it's the politest thing you can do in a hot loop. letting other threads have a turn? iconic behaviour, no cap 🧚


🫢 Author 🫢

Generated automatically by Doxygen for libstdc++ from the source code. (not a human author, just a robot doing its best 😭 we love a machine-generated queen)


bestie reminder: every one of these is inline, and the noexcept ones are get_id() and yield(). sleep_for() and sleep_until() are linked to each other β€” sleep_until() references sleep_for(), and sleep_for() is referenced by sleep_until(). periodt πŸ’–

okay that's the whole page!! this came to you from libstdc++ and it's filed under std::this_thread(3) in the manual β€” stay sleepy, stay yieldy, and always know your own thread id, bestie πŸŒΈπŸ’œβœ¨

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms