1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:07:36 +00:00

Kernel: Make Threads always have a name

We previously allowed Thread to exist in a state where its m_name was
null, and had to work around that in various places.

This patch removes that possibility and forces those who would create a
thread (or change the name of one) to provide a NonnullOwnPtr<KString>
with the name.
This commit is contained in:
Andreas Kling 2021-09-06 12:44:27 +02:00
parent cda2b9e71c
commit 7981422500
7 changed files with 25 additions and 13 deletions

View file

@ -194,10 +194,10 @@ public:
{
// NOTE: Whoever is calling this needs to be holding our lock while reading the name.
VERIFY(m_lock.is_locked_by_current_processor());
return m_name ? m_name->view() : StringView {};
return m_name->view();
}
void set_name(OwnPtr<KString> name)
void set_name(NonnullOwnPtr<KString> name)
{
SpinlockLocker lock(m_lock);
m_name = move(name);
@ -1202,7 +1202,7 @@ public:
String backtrace();
private:
Thread(NonnullRefPtr<Process>, NonnullOwnPtr<Memory::Region>, NonnullRefPtr<Timer>, OwnPtr<KString>);
Thread(NonnullRefPtr<Process>, NonnullOwnPtr<Memory::Region>, NonnullRefPtr<Timer>, NonnullOwnPtr<KString>);
IntrusiveListNode<Thread> m_process_thread_list_node;
int m_runnable_priority { -1 };
@ -1333,7 +1333,7 @@ private:
FPUState m_fpu_state {};
State m_state { Invalid };
OwnPtr<KString> m_name;
NonnullOwnPtr<KString> m_name;
u32 m_priority { THREAD_PRIORITY_NORMAL };
State m_stop_state { Invalid };