ThreadSchedule 1.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 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
  • Must be constructed from the thread it represents (delegates to ThreadControlBlock::create_for_current_thread()).
  • On Linux, the name must be at most 15 characters (POSIX thread name limit); longer names cause ThreadControlBlock::set_name() to fail, but the thread is still registered.

Definition at line 1026 of file thread_registry.hpp.

Constructor & Destructor Documentation

◆ AutoRegisterCurrentThread() [1/3]

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

Definition at line 1029 of file thread_registry.hpp.

◆ AutoRegisterCurrentThread() [2/3]

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

Definition at line 1038 of file thread_registry.hpp.

◆ ~AutoRegisterCurrentThread()

threadschedule::AutoRegisterCurrentThread::~AutoRegisterCurrentThread ( )
inline

Definition at line 1046 of file thread_registry.hpp.

◆ AutoRegisterCurrentThread() [3/3]

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

Definition at line 1058 of file thread_registry.hpp.

Member Function Documentation

◆ operator=()

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

Definition at line 1064 of file thread_registry.hpp.


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