mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
Kernel: Add a Thread::set_thread_list() helper to keep logic in one place.
This commit is contained in:
parent
8c7d5abdc4
commit
64a4f3df69
Notes:
sideshowbarker
2024-07-19 14:01:59 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/64a4f3df697
@ -73,8 +73,7 @@ Thread::Thread(Process& process)
|
||||
if (m_process.pid() != 0) {
|
||||
InterruptDisabler disabler;
|
||||
thread_table().set(this);
|
||||
g_nonrunnable_threads->prepend(this);
|
||||
m_thread_list = g_nonrunnable_threads;
|
||||
set_thread_list(g_nonrunnable_threads);
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,14 +544,19 @@ bool Thread::is_thread(void* ptr)
|
||||
return thread_table().contains((Thread*)ptr);
|
||||
}
|
||||
|
||||
void Thread::set_state(State new_state)
|
||||
void Thread::set_thread_list(InlineLinkedList<Thread>* thread_list)
|
||||
{
|
||||
m_state = new_state;
|
||||
auto* new_thread_list = thread_list_for_state(new_state);
|
||||
if (m_thread_list == new_thread_list)
|
||||
if (m_thread_list == thread_list)
|
||||
return;
|
||||
if (m_thread_list)
|
||||
m_thread_list->remove(this);
|
||||
new_thread_list->append(this);
|
||||
m_thread_list = new_thread_list;
|
||||
if (thread_list)
|
||||
thread_list->append(this);
|
||||
m_thread_list = thread_list;
|
||||
}
|
||||
|
||||
void Thread::set_state(State new_state)
|
||||
{
|
||||
m_state = new_state;
|
||||
set_thread_list(thread_list_for_state(new_state));
|
||||
}
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
Thread* m_next { nullptr };
|
||||
|
||||
InlineLinkedList<Thread>* thread_list() { return m_thread_list; }
|
||||
void set_thread_list(InlineLinkedList<Thread>*);
|
||||
|
||||
template<typename Callback> static void for_each_in_state(State, Callback);
|
||||
template<typename Callback> static void for_each_living(Callback);
|
||||
|
Loading…
Reference in New Issue
Block a user