Loop through queue and find matcxhing signal handlers for the first event of each queue

This commit is contained in:
Tristan B. Velloza Kildaire 2021-08-31 11:39:41 +02:00
parent 349f3d3ddd
commit 8da3dd2b4a
1 changed files with 42 additions and 0 deletions

View File

@ -42,10 +42,52 @@ public final class Engine
{
/* TODO: Implement me */
/* Lock the queue-set */
queueLock.lock();
foreach(Queue queue; queues)
{
/* If the queue has evenets queued */
if(queue.hasEvents())
{
/* TODO: Add different dequeuing techniques */
/* Pop the first Event */
Event headEvent = queue.popEvent();
/* Get all signal-handlers for this event type */
Signal[] handlersMatched = getSignalsForEvent(headEvent);
}
}
/* Unlock the queue set */
queueLock.unlock();
/* TODO: Add yield to stop mutex starvation on a single thread */
}
}
private Signal[] getSignalsForEvent(Event e)
{
/* Matched handlers */
Signal[] matchedHandlers;
/* Lock the signal-set */
handlerLock.lock();
/* Find all handlers matching */
foreach(Signal signal; handlers)
{
matchedHandlers ~= signal;
}
/* Unlock the signal-set */
handlerLock.unlock();
return matchedHandlers;
}
/**
* push(Event e)
*