瀏覽代碼

Process: Now that Thread::for_each are composable, we can reuse them rather than rewriting them

This avoids exposing the runnable lists to Process.
Robin Burchell 6 年之前
父節點
當前提交
3727a06c78
共有 1 個文件被更改,包括 6 次插入16 次删除
  1. 6 16
      Kernel/Process.h

+ 6 - 16
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<typename Callback>