summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-22 17:38:16 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-23 00:02:09 +0200
commitb30081b49ac91953073fec0420652cb605a85388 (patch)
treeb9940618c1b682dd6b73f355c9ac05acb120df2f
parent6c16bedd69b7ce8d132888b0f7cf04949163bc0e (diff)
downloadserenity-b30081b49ac91953073fec0420652cb605a85388.zip
Kernel: Rename BlockerSet::unblock() to something more accurate
Namely, unblock_all_blockers_whose_conditions_are_met(). The old name made it sound like things were getting unblocked no matter what, but that's not actually the case. What this actually does is iterate through the set of blockers, unblocking those whose conditions are met. So give it a (very) verbose name that errs on the side of descriptiveness.
-rw-r--r--Kernel/FileSystem/File.h6
-rw-r--r--Kernel/FileSystem/FileDescription.h2
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp4
-rw-r--r--Kernel/FutexQueue.cpp6
-rw-r--r--Kernel/Net/Routing.cpp2
-rw-r--r--Kernel/Thread.h20
-rw-r--r--Kernel/ThreadBlockers.cpp4
-rw-r--r--Kernel/WaitQueue.cpp6
8 files changed, 25 insertions, 25 deletions
diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h
index dc5977ee70..276a383747 100644
--- a/Kernel/FileSystem/File.h
+++ b/Kernel/FileSystem/File.h
@@ -32,10 +32,10 @@ public:
return !blocker.unblock(true, data);
}
- void unblock()
+ void unblock_all_blockers_whose_conditions_are_met()
{
SpinlockLocker lock(m_lock);
- do_unblock([&](auto& b, void* data, bool&) {
+ BlockerSet::unblock_all_blockers_whose_conditions_are_met_locked([&](auto& b, void* data, bool&) {
VERIFY(b.blocker_type() == Thread::Blocker::Type::File);
auto& blocker = static_cast<Thread::FileBlocker&>(b);
return blocker.unblock(false, data);
@@ -138,7 +138,7 @@ private:
ALWAYS_INLINE void do_evaluate_block_conditions()
{
VERIFY(!Processor::current_in_irq());
- blocker_set().unblock();
+ blocker_set().unblock_all_blockers_whose_conditions_are_met();
}
FileBlockerSet m_blocker_set;
diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h
index d5f3992487..05bd10e4c4 100644
--- a/Kernel/FileSystem/FileDescription.h
+++ b/Kernel/FileSystem/FileDescription.h
@@ -138,7 +138,7 @@ private:
void evaluate_block_conditions()
{
- blocker_set().unblock();
+ blocker_set().unblock_all_blockers_whose_conditions_are_met();
}
RefPtr<Custody> m_custody;
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index 6861274a55..7bedfd5997 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -451,7 +451,7 @@ bool Plan9FS::Plan9FSBlockerSet::should_add_blocker(Thread::Blocker& b, void*)
void Plan9FS::Plan9FSBlockerSet::unblock_completed(u16 tag)
{
- unblock([&](Thread::Blocker& b, void*, bool&) {
+ unblock_all_blockers_whose_conditions_are_met([&](Thread::Blocker& b, void*, bool&) {
VERIFY(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
auto& blocker = static_cast<Blocker&>(b);
return blocker.unblock(tag);
@@ -460,7 +460,7 @@ void Plan9FS::Plan9FSBlockerSet::unblock_completed(u16 tag)
void Plan9FS::Plan9FSBlockerSet::unblock_all()
{
- unblock([&](Thread::Blocker& b, void*, bool&) {
+ unblock_all_blockers_whose_conditions_are_met([&](Thread::Blocker& b, void*, bool&) {
VERIFY(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
auto& blocker = static_cast<Blocker&>(b);
return blocker.unblock();
diff --git a/Kernel/FutexQueue.cpp b/Kernel/FutexQueue.cpp
index 2d747ea1de..06ecf92949 100644
--- a/Kernel/FutexQueue.cpp
+++ b/Kernel/FutexQueue.cpp
@@ -44,7 +44,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function<FutexQueue*()>& ge
dbgln_if(FUTEXQUEUE_DEBUG, "FutexQueue @ {}: wake_n_requeue({}, {})", this, wake_count, requeue_count);
u32 did_wake = 0, did_requeue = 0;
- do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
@@ -103,7 +103,7 @@ u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_emp
SpinlockLocker lock(m_lock);
dbgln_if(FUTEXQUEUE_DEBUG, "FutexQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0;
- do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
@@ -126,7 +126,7 @@ u32 FutexQueue::wake_all(bool& is_empty)
SpinlockLocker lock(m_lock);
dbgln_if(FUTEXQUEUE_DEBUG, "FutexQueue @ {}: wake_all", this);
u32 did_wake = 0;
- do_unblock([&](Thread::Blocker& b, void* data, bool&) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool&) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Futex);
auto& blocker = static_cast<Thread::FutexBlocker&>(b);
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 2b4d620911..89223cdcca 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -59,7 +59,7 @@ class ARPTableBlockerSet final : public Thread::BlockerSet {
public:
void unblock(const IPv4Address& ip_addr, const MACAddress& addr)
{
- BlockerSet::unblock([&](auto& b, void*, bool&) {
+ BlockerSet::unblock_all_blockers_whose_conditions_are_met([&](auto& b, void*, bool&) {
VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing);
auto& blocker = static_cast<ARPTableBlocker&>(b);
return blocker.unblock(false, ip_addr, addr);
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 8bb7ed1d6e..4a954c0308 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -427,30 +427,30 @@ public:
}
protected:
- template<typename UnblockOne>
- bool unblock(UnblockOne unblock_one)
+ template<typename Callback>
+ bool unblock_all_blockers_whose_conditions_are_met(Callback try_to_unblock_one)
{
SpinlockLocker lock(m_lock);
- return do_unblock(unblock_one);
+ return unblock_all_blockers_whose_conditions_are_met_locked(try_to_unblock_one);
}
- template<typename UnblockOne>
- bool do_unblock(UnblockOne unblock_one)
+ template<typename Callback>
+ bool unblock_all_blockers_whose_conditions_are_met_locked(Callback try_to_unblock_one)
{
VERIFY(m_lock.is_locked());
bool stop_iterating = false;
- bool did_unblock = false;
+ bool did_unblock_any = false;
for (size_t i = 0; i < m_blockers.size() && !stop_iterating;) {
auto& info = m_blockers[i];
- if (unblock_one(*info.blocker, info.data, stop_iterating)) {
+ if (bool did_unblock = try_to_unblock_one(*info.blocker, info.data, stop_iterating)) {
m_blockers.remove(i);
- did_unblock = true;
+ did_unblock_any = true;
continue;
}
i++;
}
- return did_unblock;
+ return did_unblock_any;
}
bool is_empty_locked() const
@@ -1267,7 +1267,7 @@ private:
private:
void do_unblock_joiner()
{
- do_unblock([&](Blocker& b, void*, bool&) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Blocker& b, void*, bool&) {
VERIFY(b.blocker_type() == Blocker::Type::Join);
auto& blocker = static_cast<JoinBlocker&>(b);
return blocker.unblock(exit_value(), false);
diff --git a/Kernel/ThreadBlockers.cpp b/Kernel/ThreadBlockers.cpp
index c67e30d401..fd2ac4a06f 100644
--- a/Kernel/ThreadBlockers.cpp
+++ b/Kernel/ThreadBlockers.cpp
@@ -478,7 +478,7 @@ void Thread::WaitBlockerSet::disowned_by_waiter(Process& process)
for (size_t i = 0; i < m_processes.size();) {
auto& info = m_processes[i];
if (info.process == &process) {
- do_unblock([&](Blocker& b, void*, bool&) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Blocker& b, void*, bool&) {
VERIFY(b.blocker_type() == Blocker::Type::Wait);
auto& blocker = static_cast<WaitBlocker&>(b);
bool did_unblock = blocker.unblock(info.process, WaitBlocker::UnblockFlags::Disowned, 0, false);
@@ -515,7 +515,7 @@ bool Thread::WaitBlockerSet::unblock(Process& process, WaitBlocker::UnblockFlags
}
}
- do_unblock([&](Blocker& b, void*, bool&) {
+ unblock_all_blockers_whose_conditions_are_met_locked([&](Blocker& b, void*, bool&) {
VERIFY(b.blocker_type() == Blocker::Type::Wait);
auto& blocker = static_cast<WaitBlocker&>(b);
if (was_waited_already && blocker.is_wait())
diff --git a/Kernel/WaitQueue.cpp b/Kernel/WaitQueue.cpp
index 6d0ae360e1..65c74b3bdb 100644
--- a/Kernel/WaitQueue.cpp
+++ b/Kernel/WaitQueue.cpp
@@ -29,7 +29,7 @@ u32 WaitQueue::wake_one()
u32 did_wake = 0;
SpinlockLocker lock(m_lock);
dbgln_if(WAITQUEUE_DEBUG, "WaitQueue @ {}: wake_one", this);
- bool did_unblock_one = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
+ bool did_unblock_one = unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
@@ -54,7 +54,7 @@ u32 WaitQueue::wake_n(u32 wake_count)
dbgln_if(WAITQUEUE_DEBUG, "WaitQueue @ {}: wake_n({})", this, wake_count);
u32 did_wake = 0;
- bool did_unblock_some = do_unblock([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
+ bool did_unblock_some = unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool& stop_iterating) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);
@@ -79,7 +79,7 @@ u32 WaitQueue::wake_all()
dbgln_if(WAITQUEUE_DEBUG, "WaitQueue @ {}: wake_all", this);
u32 did_wake = 0;
- bool did_unblock_any = do_unblock([&](Thread::Blocker& b, void* data, bool&) {
+ bool did_unblock_any = unblock_all_blockers_whose_conditions_are_met_locked([&](Thread::Blocker& b, void* data, bool&) {
VERIFY(data);
VERIFY(b.blocker_type() == Thread::Blocker::Type::Queue);
auto& blocker = static_cast<Thread::QueueBlocker&>(b);