mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Kernel: Minor Lock optimization
This commit is contained in:
@@ -52,8 +52,7 @@ void Lock::lock(Mode mode)
|
|||||||
}
|
}
|
||||||
auto current_thread = Thread::current();
|
auto current_thread = Thread::current();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
bool expected = false;
|
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
|
||||||
if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) {
|
|
||||||
do {
|
do {
|
||||||
// FIXME: Do not add new readers if writers are queued.
|
// FIXME: Do not add new readers if writers are queued.
|
||||||
bool modes_dont_conflict = !modes_conflict(m_mode, mode);
|
bool modes_dont_conflict = !modes_conflict(m_mode, mode);
|
||||||
@@ -91,8 +90,7 @@ void Lock::unlock()
|
|||||||
{
|
{
|
||||||
auto current_thread = Thread::current();
|
auto current_thread = Thread::current();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
bool expected = false;
|
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
|
||||||
if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) {
|
|
||||||
ASSERT(m_times_locked);
|
ASSERT(m_times_locked);
|
||||||
--m_times_locked;
|
--m_times_locked;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user