mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 07:07:36 +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
|
@ -404,7 +404,6 @@ void Thread::finalize_dying_threads()
|
|||
for_each_in_state(Thread::State::Dying, [&](Thread& thread) {
|
||||
if (thread.is_finalizable())
|
||||
dying_threads.append(&thread);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
for (auto* thread : dying_threads) {
|
||||
|
@ -740,7 +739,6 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
|
|||
process.set_dump_core(true);
|
||||
process.for_each_thread([](auto& thread) {
|
||||
thread.set_dump_backtrace_on_finalization();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
[[fallthrough]];
|
||||
case DefaultSignalAction::Terminate:
|
||||
|
@ -891,11 +889,12 @@ void Thread::set_state(State new_state, u8 stop_signal)
|
|||
auto& process = this->process();
|
||||
if (process.set_stopped(false) == true) {
|
||||
process.for_each_thread([&](auto& thread) {
|
||||
if (&thread == this || !thread.is_stopped())
|
||||
return IterationDecision::Continue;
|
||||
if (&thread == this)
|
||||
return;
|
||||
if (!thread.is_stopped())
|
||||
return;
|
||||
dbgln_if(THREAD_DEBUG, "Resuming peer thread {}", thread);
|
||||
thread.resume_from_stopped();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
process.unblock_waiters(Thread::WaitBlocker::UnblockFlags::Continued);
|
||||
// Tell the parent process (if any) about this change.
|
||||
|
@ -914,11 +913,12 @@ void Thread::set_state(State new_state, u8 stop_signal)
|
|||
auto& process = this->process();
|
||||
if (process.set_stopped(true) == false) {
|
||||
process.for_each_thread([&](auto& thread) {
|
||||
if (&thread == this || thread.is_stopped())
|
||||
return IterationDecision::Continue;
|
||||
if (&thread == this)
|
||||
return;
|
||||
if (thread.is_stopped())
|
||||
return;
|
||||
dbgln_if(THREAD_DEBUG, "Stopping peer thread {}", thread);
|
||||
thread.set_state(Stopped, stop_signal);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
process.unblock_waiters(Thread::WaitBlocker::UnblockFlags::Stopped, stop_signal);
|
||||
// Tell the parent process (if any) about this change.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue