From 33655188fe4b9bcfad1e98a05e9ebcc22afc7ef8 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 14 Dec 2022 16:38:06 +0100 Subject: [PATCH] Don't use pthread_self/GetCurrentThreadId where not needed in logging module Use std::this_thread::get_id instead. --- .../src/format/formatter/thread_id.cpp | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/libs/pika/logging/src/format/formatter/thread_id.cpp b/libs/pika/logging/src/format/formatter/thread_id.cpp index df279666e2..bb100f11de 100644 --- a/libs/pika/logging/src/format/formatter/thread_id.cpp +++ b/libs/pika/logging/src/format/formatter/thread_id.cpp @@ -22,17 +22,12 @@ #include #include #include +#include #include #include #include -#if defined(PIKA_WINDOWS) -#include -#else -#include -#endif - namespace pika::util::logging::formatter { thread_id::~thread_id() = default; @@ -41,20 +36,8 @@ namespace pika::util::logging::formatter { { void operator()(std::ostream& to) const override { - auto id = -#if defined(PIKA_WINDOWS) - ::GetCurrentThreadId(); -#else - pthread_self(); -#endif - if constexpr (std::is_pointer_v) - { - fmt::print(to, "{}", fmt::ptr(id)); - } - else - { - fmt::print(to, "{}", id); - } + auto id = std::this_thread::get_id(); + fmt::print(to, "{}", id); } };