1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Kernel: Simplify Blockers so they don't need a "should block" flag

The `m_should_block` member variable that many of the Thread::Blocker
subclasses had was really only used to carry state from the constructor
to the immediate-unblock-without-blocking escape hatch.

This patch refactors the blockers so that we don't need to hold on
to this flag after setup_blocker(), and instead the return value from
setup_blocker() is the authority on whether the unblock conditions
are already met.
This commit is contained in:
Andreas Kling 2021-08-24 13:11:58 +02:00
parent adbf472ca7
commit 0c1d41cc8a
3 changed files with 26 additions and 51 deletions

View file

@ -52,7 +52,6 @@ private:
const IPv4Address m_ip_addr;
Optional<MACAddress>& m_addr;
bool m_did_unblock { false };
bool m_should_block { true };
};
class ARPTableBlockerSet final : public Thread::BlockerSet {
@ -90,14 +89,11 @@ ARPTableBlocker::ARPTableBlocker(IPv4Address ip_addr, Optional<MACAddress>& addr
bool ARPTableBlocker::setup_blocker()
{
if (!add_to_blocker_set(*s_arp_table_blocker_set))
m_should_block = false;
return m_should_block;
return add_to_blocker_set(*s_arp_table_blocker_set);
}
void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason reason)
void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason)
{
VERIFY(reason == UnblockImmediatelyReason::TimeoutInThePast || !m_should_block);
auto addr = arp_table().with_shared([&](const auto& table) -> auto {
return table.get(ip_addr());
});