WIP: Event dispatching loop

This commit is contained in:
Tristan B. Velloza Kildaire 2022-03-16 17:10:15 +02:00
parent 21e1b91abc
commit 4c798aef6a
1 changed files with 52 additions and 0 deletions

View File

@ -8,6 +8,7 @@
module tasky.engine;
import eventy.engine : EvEngine = Engine;
import eventy.event : Event;
import tasky.jobs : Descriptor;
import tristanable;
import std.socket : Socket;
@ -40,6 +41,17 @@ public final class Engine : Thread
tmanager = new Manager(socket);
}
public class TaskyEvent : Event
{
private byte[] payload;
this(ulong descID, byte[] payload)
{
super(descID);
this.payload = payload;
}
}
/**
* Worker thread function which checks the tristanable
@ -50,10 +62,50 @@ public final class Engine : Thread
{
while(true)
{
/* TODO: Get all tristanable queues */
Queue[] tQueues = tmanager.getQueues();
foreach(Queue tQueue; tQueues)
{
/* Descriptor ID */
ulong descID = tQueue.getTag();
/* Check if the queue has mail */
/* TODO: Different discplines here, full-exhaust or round robin queue */
if(tQueue.poll())
{
/* Get the data */
QueueItem data = tQueue.dequeue();
evEngine.push(new TaskyEvent(descID, data.getData()));
// d.
// data.getData()
// evEngine.push
}
}
/* TODO: Use queue ID to match to descriptor id for later job dispatch */
/* TODO: Per each queue */
}
}
/**
* TODO: Dispatcher
*/
private void dispatch()
{
}
/**
* Register a Descriptor with tasky