Initial optimizations (Squashed to fix submodules)
This commit is contained in:
+12
-2
@@ -14,7 +14,10 @@ void shared_mutex::imp_lock_shared(s64 _old)
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
busy_wait();
|
||||
if (i != 0)
|
||||
{
|
||||
busy_wait();
|
||||
}
|
||||
|
||||
const s64 value = m_value.load();
|
||||
|
||||
@@ -173,7 +176,10 @@ void shared_mutex::imp_lock(s64 _old)
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
busy_wait();
|
||||
if (i != 0)
|
||||
{
|
||||
busy_wait();
|
||||
}
|
||||
|
||||
const s64 value = m_value.load();
|
||||
|
||||
@@ -236,6 +242,10 @@ void shared_mutex::imp_lock_degrade()
|
||||
|
||||
bool shared_mutex::try_lock_shared()
|
||||
{
|
||||
if (m_value < c_min) // Fast path
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Conditional decrement
|
||||
return m_value.fetch_op([](s64& value) { if (value >= c_min) value -= c_min; }) >= c_min;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user