Initial optimizations (Squashed to fix submodules)

This commit is contained in:
Farseer 2018-01-25 11:51:11 +02:00 committed by Zangetsu38
parent db96c355ce
commit 2d4af4c88c
13 changed files with 426 additions and 558 deletions

View file

@ -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;
}