mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +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:
parent
d6667e4cb8
commit
b197fc40a7
Notes:
sideshowbarker
2024-07-18 07:19:14 +09:00
Author: https://github.com/awesomekling
Commit: b197fc40a7
3 changed files with 38 additions and 27 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue