mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 02:40:49 +00:00
Kernel: Port process thread lists to SpinLockProtectedValue
I had to move the thread list out of the protected base area of Process so that it could live with its lock (which needs to be mutable). Ideally it would live in the protected area, so maybe we can figure out a way to do that later.
This commit is contained in:
@@ -856,8 +856,9 @@ bool Process::remove_thread(Thread& thread)
|
||||
ProtectedDataMutationScope scope { *this };
|
||||
auto thread_cnt_before = m_thread_count.fetch_sub(1, AK::MemoryOrder::memory_order_acq_rel);
|
||||
VERIFY(thread_cnt_before != 0);
|
||||
ScopedSpinLock thread_list_lock(m_thread_list_lock);
|
||||
m_thread_list.remove(thread);
|
||||
thread_list().with([&](auto& thread_list) {
|
||||
thread_list.remove(thread);
|
||||
});
|
||||
return thread_cnt_before == 1;
|
||||
}
|
||||
|
||||
@@ -865,8 +866,9 @@ bool Process::add_thread(Thread& thread)
|
||||
{
|
||||
ProtectedDataMutationScope scope { *this };
|
||||
bool is_first = m_thread_count.fetch_add(1, AK::MemoryOrder::memory_order_relaxed) == 0;
|
||||
ScopedSpinLock thread_list_lock(m_thread_list_lock);
|
||||
m_thread_list.append(thread);
|
||||
thread_list().with([&](auto& thread_list) {
|
||||
thread_list.append(thread);
|
||||
});
|
||||
return is_first;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user