logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Author

       Generated automatically by Doxygen for libstdc++ from the source code.

                                                    libstdc++                                 std::jthread(3cxx)

Detailed Description

       A thread with cancellation and automatic joining.

       Unlike std::thread, destroying a joinable std::jthread will not terminate the process. Instead, it will
       try to request its thread to stop, then will join it.

       A std::jthread has a std::stop_source member which will be passed as the first argument to the callable
       that runs in the new thread (as long as the callable will accept that argument). That can then be used to
       send a stop request that the new thread can test for.

       Since
           C++20

Name

       std::jthread

Synopsis

       #include <thread>

   PublicTypesusingid = thread::idusingnative_handle_type = thread::native_handle_type

   PublicMemberFunctions
       template<typename _Callable , typename... _Args, typename  =
           enable_if_t<!is_same_v<remove_cvref_t<_Callable>,                                jthread>>> jthread
           (_Callable &&__f, _Args &&... __args)
       jthread (const jthread &)=deletejthread (jthread &&) noexcept=defaultvoiddetach ()
       idget_id () const noexcept
       stop_sourceget_stop_source () noexcept
       stop_tokenget_stop_token () const noexcept
       voidjoin ()
       bool joinable () const noexcept
       native_handle_type native_handle ()
       jthread & operator= (const jthread &)=deletejthread & operator= (jthread &&__other) noexcept
       bool request_stop () noexcept
       voidswap (jthread &__other) noexcept

   StaticPublicMemberFunctionsstatic unsigned hardware_concurrency () noexcept

   Friendsvoidswap (jthread &__lhs, jthread &__rhs) noexcept

See Also