Fix missed attempt increment in spinlock

Should hog CPU slightly less and correctly yield now
This commit is contained in:
Billy Laws 2022-12-31 23:03:18 +00:00
parent 35a46acbb1
commit 4e5141f879

View File

@ -18,6 +18,7 @@ namespace skyline {
if (!locked.test_and_set(std::memory_order_acquire)) if (!locked.test_and_set(std::memory_order_acquire))
return; return;
attempt++;
if (attempt % LockAttemptsPerSleep == 0) if (attempt % LockAttemptsPerSleep == 0)
std::this_thread::sleep_for(std::chrono::microseconds(100)); std::this_thread::sleep_for(std::chrono::microseconds(100));
else if (attempt % LockAttemptsPerYield == 0) else if (attempt % LockAttemptsPerYield == 0)