summaryrefslogtreecommitdiff
path: root/Kernel/Thread.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-24 01:01:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-24 01:57:11 +0200
commita58c4bbcf50dfae2e8e7432e6728fd90ccaf80ad (patch)
tree3ae3c2046b72fa961e468877dff867f2d176a847 /Kernel/Thread.h
parentc35194547409b1218f5d50ce65e8f5c3968fabba (diff)
downloadserenity-a58c4bbcf50dfae2e8e7432e6728fd90ccaf80ad.zip
Kernel: Make Thread::Blocker::m_thread a NonnullRefPtr<Thread>
There's no harm in the blocker always knowing which thread it originated from. It also simplifies some logic since we don't need to think about it ever being null.
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r--Kernel/Thread.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 91d2b065b6..3eef612e0d 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -346,7 +346,10 @@ public:
BlockResult end_blocking(Badge<Thread>, bool);
protected:
- Blocker() { }
+ Blocker()
+ : m_thread(*Thread::current())
+ {
+ }
void do_set_interrupted_by_death()
{
@@ -371,19 +374,14 @@ public:
}
void unblock_from_blocker()
{
- RefPtr<Thread> thread;
-
{
SpinlockLocker lock(m_lock);
- if (m_is_blocking) {
- m_is_blocking = false;
- VERIFY(m_blocked_thread);
- thread = m_blocked_thread;
- }
+ if (!m_is_blocking)
+ return;
+ m_is_blocking = false;
}
- if (thread)
- thread->unblock_from_blocker(*this);
+ m_thread->unblock_from_blocker(*this);
}
bool add_to_blocker_set(BlockerSet&, void* = nullptr);
@@ -393,7 +391,7 @@ public:
private:
BlockerSet* m_blocker_set { nullptr };
- Thread* m_blocked_thread { nullptr };
+ NonnullRefPtr<Thread> m_thread;
u8 m_was_interrupted_by_signal { 0 };
bool m_is_blocking { false };
bool m_was_interrupted_by_death { false };