Implemented `agressiveTryLock` check so the user can choose whether or not to yield if a fail to grab the lock occurs

This commit is contained in:
Tristan B. Velloza Kildaire 2022-11-26 17:26:05 +02:00
parent 3603c567e8
commit 59d0253b61
1 changed files with 6 additions and 4 deletions

View File

@ -251,13 +251,15 @@ public final class Engine : Thread
/**
* Lock the queue-set
*
* Additionally:
* Don't waste time spinning on mutex,
* if it is not lockable then yield
* TODO: Maybe add sleep support here too?
*/
while (!queueLock.tryLock_nothrow())
{
yield();
// Don't waste time spinning on mutex, yield if failed
if(!settings.agressiveTryLock)
{
yield();
}
}
foreach (Queue queue; queues)