mirror of https://github.com/deavmi/eventy.git
Don't waste time spinning on a mutex that cannot be unlocked, yield as it may be unlocked by another process, if not then whenever we get back here try again (repeat if same result), else fall through with lock, execute event loop, unlock and yield (as per normal)
This commit is contained in:
parent
217688767a
commit
f5ed565912
|
@ -109,8 +109,22 @@ public final class Engine : Thread
|
|||
{
|
||||
/* TODO: Implement me */
|
||||
|
||||
/* Lock the queue-set */
|
||||
queueLock.lock();
|
||||
/**
|
||||
* TODO: If lock fails, then yield
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lock the queue-set
|
||||
*
|
||||
* Additionally:
|
||||
* Don't waste time spinning on mutex,
|
||||
* if it is not lockable then yield
|
||||
*/
|
||||
while(!queueLock.tryLock_nothrow())
|
||||
{
|
||||
yield();
|
||||
}
|
||||
|
||||
|
||||
foreach(Queue queue; queues)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue