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