mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
This commit is contained in:
parent
bbaa463032
commit
aa4d41fe2c
25 changed files with 311 additions and 127 deletions
|
@ -103,15 +103,16 @@ void Process::kill_threads_except_self()
|
|||
|
||||
auto current_thread = Thread::current();
|
||||
for_each_thread([&](Thread& thread) {
|
||||
if (&thread == current_thread
|
||||
|| thread.state() == Thread::State::Dead
|
||||
|| thread.state() == Thread::State::Dying)
|
||||
return IterationDecision::Continue;
|
||||
if (&thread == current_thread)
|
||||
return;
|
||||
|
||||
if (auto state = thread.state(); state == Thread::State::Dead
|
||||
|| state == Thread::State::Dying)
|
||||
return;
|
||||
|
||||
// We need to detach this thread in case it hasn't been joined
|
||||
thread.detach();
|
||||
thread.set_should_die();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
big_lock().clear_waiters();
|
||||
|
@ -123,7 +124,6 @@ void Process::kill_all_threads()
|
|||
// We need to detach this thread in case it hasn't been joined
|
||||
thread.detach();
|
||||
thread.set_should_die();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,6 @@ void Process::die()
|
|||
|
||||
for_each_thread([&](auto& thread) {
|
||||
m_threads_for_coredump.append(thread);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue