1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:28:11 +00:00

LibThread: Allow setting thread name in constructor

Thread now has an optional thread_name parameter to the consturctor
that will call pthread_setname_np if given.
This commit is contained in:
Andrew Kaster 2019-12-07 12:49:05 -07:00 committed by Andreas Kling
parent baf7e247e3
commit 0b38a553b1
2 changed files with 9 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include <AK/Function.h>
#include <AK/String.h>
#include <LibCore/CObject.h>
namespace LibThread {
@ -9,7 +10,7 @@ class Thread final : public CObject {
C_OBJECT(Thread);
public:
explicit Thread(Function<int()> action);
explicit Thread(Function<int()> action, StringView thread_name = nullptr);
virtual ~Thread();
void start();
@ -18,6 +19,7 @@ public:
private:
Function<int()> m_action;
int m_tid { -1 };
String m_thread_name;
};
}