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_fortemplate<typename _Clock, typename _Duration> void sleep_until (const chrono::time_point< _Clock, _Duration > &__atime)βthis_thread::sleep_untilvoid 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 isinline, and thenoexceptones areget_id()andyield().sleep_for()andsleep_until()are linked to each other βsleep_until()referencessleep_for(), andsleep_for()is referenced bysleep_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