summaryrefslogtreecommitdiff
path: root/Kernel/ThreadBlockers.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-24 00:34:11 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-24 01:57:11 +0200
commitc35194547409b1218f5d50ce65e8f5c3968fabba (patch)
tree3cf0b3612820f9ab2888c0cccf7aeec91c130111 /Kernel/ThreadBlockers.cpp
parent6ce05026b4a4530b43607261b9416178ae79af7d (diff)
downloadserenity-c35194547409b1218f5d50ce65e8f5c3968fabba.zip
Kernel: Simplify unregistering a Blocker from a BlockerSet
The BlockerSet stores its blockers along with a "void* data" that may contain some blocker-specific context relevant to the specific blocker registration (for example, SelectBlocker stores a pointer to the relevant entry in an array of SelectBlocker::FDInfo structs.) When unregistering a blocker from a set, we don't need to key the blocker by both the Blocker* and the data. Just the Blocker* is enough, since all registrations for that blocker need to be removed anyway as the blocker is about to be destroyed. So we stop passing the "void* data" to BlockerSet::remove_blocker(), which also allows us to remove the now-unneeded Blocker::m_block_data.
Diffstat (limited to 'Kernel/ThreadBlockers.cpp')
-rw-r--r--Kernel/ThreadBlockers.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/Kernel/ThreadBlockers.cpp b/Kernel/ThreadBlockers.cpp
index 116bd46e21..a8f4551c12 100644
--- a/Kernel/ThreadBlockers.cpp
+++ b/Kernel/ThreadBlockers.cpp
@@ -33,7 +33,6 @@ bool Thread::Blocker::add_to_blocker_set(Thread::BlockerSet& blocker_set, void*
VERIFY(!m_blocker_set);
if (blocker_set.add_blocker(*this, data)) {
m_blocker_set = &blocker_set;
- m_block_data = data;
return true;
}
return false;
@@ -43,7 +42,7 @@ Thread::Blocker::~Blocker()
{
VERIFY(!m_lock.is_locked());
if (m_blocker_set)
- m_blocker_set->remove_blocker(*this, m_block_data);
+ m_blocker_set->remove_blocker(*this);
}
void Thread::Blocker::begin_blocking(Badge<Thread>)
@@ -355,7 +354,7 @@ Thread::SelectBlocker::SelectBlocker(FDVector& fds)
Thread::SelectBlocker::~SelectBlocker()
{
for (auto& fd_entry : m_fds)
- fd_entry.description->blocker_set().remove_blocker(*this, &fd_entry);
+ fd_entry.description->blocker_set().remove_blocker(*this);
}
void Thread::SelectBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason reason)