ThreadSchedule 2.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::AutoRegisterCurrentThread Class Reference

RAII guard that registers the current thread on construction and unregisters it on destruction. More...

#include <thread_registry.hpp>

Public Member Functions

 AutoRegisterCurrentThread (std::string const &name=std::string(), std::string const &componentTag=std::string())
 AutoRegisterCurrentThread (ThreadRegistry &reg, std::string const &name=std::string(), std::string const &componentTag=std::string())
 ~AutoRegisterCurrentThread ()
 AutoRegisterCurrentThread (AutoRegisterCurrentThread const &)=delete
auto operator= (AutoRegisterCurrentThread const &) -> AutoRegisterCurrentThread &=delete
 AutoRegisterCurrentThread (AutoRegisterCurrentThread &&other) noexcept
auto operator= (AutoRegisterCurrentThread &&other) noexcept -> AutoRegisterCurrentThread &

Detailed Description

RAII guard that registers the current thread on construction and unregisters it on destruction.

AutoRegisterCurrentThread creates a ThreadControlBlock for the calling thread, sets its OS-visible name via ThreadControlBlock::set_name(), and registers it in either the global registry() or a caller-supplied ThreadRegistry.

Copyability / movability
  • Not copyable (deleted).
  • Movable - move construction / assignment transfers registration ownership to the new instance and disarms the source.
Thread safety
Construction and destruction interact with the target ThreadRegistry, which is itself thread-safe. The guard object itself must not be shared across threads without external synchronisation.
Lifetime / ownership
  • If constructed with a specific ThreadRegistry&, that registry must outlive this guard.
  • If constructed without an explicit registry, the global registry() singleton is used, which has static storage duration.
Typical usage
void worker_func() {
// ... thread body ...
} // automatically unregistered here
RAII guard that registers the current thread on construction and unregisters it on destruction.
Caveats

Definition at line 875 of file thread_registry.hpp.

Constructor & Destructor Documentation

◆ AutoRegisterCurrentThread() [1/4]

threadschedule::AutoRegisterCurrentThread::AutoRegisterCurrentThread ( std::string const & name = std::string(),
std::string const & componentTag = std::string() )
inlineexplicit

◆ AutoRegisterCurrentThread() [2/4]

threadschedule::AutoRegisterCurrentThread::AutoRegisterCurrentThread ( ThreadRegistry & reg,
std::string const & name = std::string(),
std::string const & componentTag = std::string() )
inlineexplicit

◆ ~AutoRegisterCurrentThread()

threadschedule::AutoRegisterCurrentThread::~AutoRegisterCurrentThread ( )
inline

Definition at line 895 of file thread_registry.hpp.

References threadschedule::registry().

◆ AutoRegisterCurrentThread() [3/4]

threadschedule::AutoRegisterCurrentThread::AutoRegisterCurrentThread ( AutoRegisterCurrentThread const & )
delete

◆ AutoRegisterCurrentThread() [4/4]

threadschedule::AutoRegisterCurrentThread::AutoRegisterCurrentThread ( AutoRegisterCurrentThread && other)
inlinenoexcept

Definition at line 907 of file thread_registry.hpp.

References AutoRegisterCurrentThread().

Member Function Documentation

◆ operator=() [1/2]

auto threadschedule::AutoRegisterCurrentThread::operator= ( AutoRegisterCurrentThread && other) -> AutoRegisterCurrentThread&
inlinenoexcept

Definition at line 913 of file thread_registry.hpp.

References AutoRegisterCurrentThread(), and threadschedule::registry().

◆ operator=() [2/2]

auto threadschedule::AutoRegisterCurrentThread::operator= ( AutoRegisterCurrentThread const & ) -> AutoRegisterCurrentThread &=delete
delete

The documentation for this class was generated from the following file: