Thread: Fix a regression introduced in 80a6df9022

Accidentally forgot to check the state parameter, which made this rather useless.

Bug found, and cause identified by Andreas
This commit is contained in:
Robin Burchell 2019-07-19 16:02:37 +02:00 committed by Andreas Kling
parent 53262cd08b
commit 4547a301c4
Notes: sideshowbarker 2024-07-19 13:08:21 +09:00

View File

@ -312,9 +312,14 @@ template<typename Callback>
inline IterationDecision Thread::for_each_in_state(State state, Callback callback)
{
ASSERT_INTERRUPTS_DISABLED();
auto new_callback = [=](Thread& thread) -> IterationDecision {
if (thread.state() == state)
return callback(thread);
return IterationDecision::Continue;
};
if (is_runnable_state(state))
return for_each_runnable(callback);
return for_each_nonrunnable(callback);
return for_each_runnable(new_callback);
return for_each_nonrunnable(new_callback);
}
template<typename Callback>