mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Move Thread::m_joinee_exit_value into the JoinBlocker
There's no need for this to be a permanent Thread member. Just use a reference in the JoinBlocker instead.
This commit is contained in:
parent
69efa3f630
commit
cb5021419e
Notes:
sideshowbarker
2024-07-19 11:13:19 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/cb5021419ea
4 changed files with 10 additions and 7 deletions
|
@ -2906,15 +2906,17 @@ int Process::sys$join_thread(int tid, void** exit_value)
|
|||
|
||||
// FIXME: EINVAL: 'thread' is not a joinable thread
|
||||
|
||||
void* joinee_exit_value = nullptr;
|
||||
|
||||
// FIXME: pthread_join() should not be interruptable. Enforce this somehow?
|
||||
auto result = current->block<Thread::JoinBlocker>(*thread);
|
||||
auto result = current->block<Thread::JoinBlocker>(*thread, joinee_exit_value);
|
||||
(void)result;
|
||||
|
||||
// NOTE: 'thread' is very possibly deleted at this point. Clear it just to be safe.
|
||||
thread = nullptr;
|
||||
|
||||
if (exit_value)
|
||||
*exit_value = current->m_joinee_exit_value;
|
||||
*exit_value = joinee_exit_value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,9 @@ void Scheduler::beep()
|
|||
s_beep_timeout = g_uptime + 100;
|
||||
}
|
||||
|
||||
Thread::JoinBlocker::JoinBlocker(Thread& joinee)
|
||||
Thread::JoinBlocker::JoinBlocker(Thread& joinee, void*& joinee_exit_value)
|
||||
: m_joinee(joinee)
|
||||
, m_joinee_exit_value(joinee_exit_value)
|
||||
{
|
||||
ASSERT(m_joinee.m_joiner == nullptr);
|
||||
m_joinee.m_joiner = current;
|
||||
|
|
|
@ -240,7 +240,7 @@ void Thread::finalize()
|
|||
|
||||
if (m_joiner) {
|
||||
ASSERT(m_joiner->m_joinee == this);
|
||||
m_joiner->m_joinee_exit_value = m_exit_value;
|
||||
static_cast<JoinBlocker*>(m_joiner->m_blocker)->set_joinee_exit_value(m_exit_value);
|
||||
m_joiner->m_joinee = nullptr;
|
||||
// NOTE: We clear the joiner pointer here as well, to be tidy.
|
||||
m_joiner = nullptr;
|
||||
|
|
|
@ -97,12 +97,14 @@ public:
|
|||
|
||||
class JoinBlocker final : public Blocker {
|
||||
public:
|
||||
explicit JoinBlocker(Thread& joinee);
|
||||
explicit JoinBlocker(Thread& joinee, void*& joinee_exit_value);
|
||||
virtual bool should_unblock(Thread&, time_t now_s, long us) override;
|
||||
virtual const char* state_string() const override { return "Joining"; }
|
||||
void set_joinee_exit_value(void* value) { m_joinee_exit_value = value; }
|
||||
|
||||
private:
|
||||
Thread& m_joinee;
|
||||
void*& m_joinee_exit_value;
|
||||
};
|
||||
|
||||
class FileDescriptionBlocker : public Blocker {
|
||||
|
@ -367,10 +369,8 @@ private:
|
|||
SignalActionData m_signal_action_data[32];
|
||||
Blocker* m_blocker { nullptr };
|
||||
|
||||
// FIXME: Some of these could probably live in the JoinBlocker object instead.
|
||||
Thread* m_joiner { nullptr };
|
||||
Thread* m_joinee { nullptr };
|
||||
void* m_joinee_exit_value { nullptr };
|
||||
void* m_exit_value { nullptr };
|
||||
|
||||
FPUState* m_fpu_state { nullptr };
|
||||
|
|
Loading…
Reference in a new issue