mirror of https://github.com/deavmi/eventy.git
Loop through queue and find matcxhing signal handlers for the first event of each queue
This commit is contained in:
parent
349f3d3ddd
commit
8da3dd2b4a
|
@ -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)
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue