From 3727a06c78fb8ac0ffa9b85614cfa3aa73fd36a0 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 19 Jul 2019 12:16:46 +0200 Subject: [PATCH] Process: Now that Thread::for_each are composable, we can reuse them rather than rewriting them This avoids exposing the runnable lists to Process. --- Kernel/Process.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Kernel/Process.h b/Kernel/Process.h index d027cfe3a4..d5e3c8e239 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -426,22 +426,12 @@ inline void Process::for_each_thread(Callback callback) const { InterruptDisabler disabler; pid_t my_pid = pid(); - for (auto* thread = g_runnable_threads->head(); thread;) { - auto* next_thread = thread->next(); - if (thread->pid() == my_pid) { - if (callback(*thread) == IterationDecision::Break) - break; - } - thread = next_thread; - } - for (auto* thread = g_nonrunnable_threads->head(); thread;) { - auto* next_thread = thread->next(); - if (thread->pid() == my_pid) { - if (callback(*thread) == IterationDecision::Break) - break; - } - thread = next_thread; - } + Thread::for_each([callback, my_pid](Thread& thread) -> IterationDecision { + if (thread.pid() == my_pid) + return callback(thread); + + return IterationDecision::Continue; + }); } template