mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
LibThreading: Only set pthread name on Serenity
pthread_setname_np is a can of worms for portability. Linux, macOS, and the BSDs all do it differently. Also skip adding the tid as an inspectable Core::Object property on systems where pthread_t is known to be a pointer.
This commit is contained in:
parent
d989c50c90
commit
2f439327ac
1 changed files with 5 additions and 0 deletions
|
@ -15,7 +15,10 @@ Threading::Thread::Thread(Function<intptr_t()> action, StringView thread_name)
|
|||
, m_thread_name(thread_name.is_null() ? ""sv : thread_name)
|
||||
{
|
||||
register_property("thread_name", [&] { return JsonValue { m_thread_name }; });
|
||||
#if defined(AK_OS_SERENITY) || defined(AK_OS_LINUX)
|
||||
// FIXME: Print out a pretty TID for BSD and macOS platforms, too
|
||||
register_property("tid", [&] { return JsonValue { m_tid }; });
|
||||
#endif
|
||||
}
|
||||
|
||||
Threading::Thread::~Thread()
|
||||
|
@ -40,10 +43,12 @@ void Threading::Thread::start()
|
|||
static_cast<void*>(this));
|
||||
|
||||
VERIFY(rc == 0);
|
||||
#ifdef AK_OS_SERENITY
|
||||
if (!m_thread_name.is_empty()) {
|
||||
rc = pthread_setname_np(m_tid, m_thread_name.characters());
|
||||
VERIFY(rc == 0);
|
||||
}
|
||||
#endif
|
||||
dbgln("Started thread \"{}\", tid = {}", m_thread_name, m_tid);
|
||||
m_started = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue