mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +00:00
Process: Now that Thread::for_each are composable, we can reuse them rather than rewriting them
This avoids exposing the runnable lists to Process.
This commit is contained in:
parent
e74dce65e6
commit
3727a06c78
Notes:
sideshowbarker
2024-07-19 13:08:57 +09:00
Author: https://github.com/rburchell Commit: https://github.com/SerenityOS/serenity/commit/3727a06c78f Pull-request: https://github.com/SerenityOS/serenity/pull/343 Reviewed-by: https://github.com/awesomekling
1 changed files with 6 additions and 16 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue