Remove support for log::register_thread(id, name); register thread name for pthread if possible

This commit is contained in:
Nikita Lisitsa 2022-08-07 11:41:23 +03:00
parent b8aeb66d07
commit f3253b1e4a
2 changed files with 11 additions and 13 deletions

View file

@ -11,20 +11,15 @@ namespace psemek::log
{
void register_thread(std::string name);
void register_thread(std::thread::id id, std::string name);
void unregister_thread(std::thread::id id);
struct [[maybe_unused]] thread_registrator
{
thread_registrator(std::string name, std::thread::id id)
: id_{id}
{
register_thread(id_, std::move(name));
}
thread_registrator(std::string name)
: thread_registrator(std::move(name), std::this_thread::get_id())
{}
: id_(std::this_thread::get_id())
{
register_thread(std::move(name));
}
~thread_registrator()
{

View file

@ -85,11 +85,14 @@ namespace psemek::log
void register_thread(std::string name)
{
register_thread(std::this_thread::get_id(), std::move(name));
}
#ifdef _PTHREAD_H
#ifdef _GNU_SOURCE
::pthread_setname_np(::pthread_self(), name.data());
#endif
#endif
auto id = std::this_thread::get_id();
void register_thread(std::thread::id id, std::string name)
{
{
std::lock_guard lock{thread_names_mutex};