Initialize tristanable, add a new tristanable queue on Descriptor registration

This commit is contained in:
Tristan B. Velloza Kildaire 2022-01-21 10:21:45 +02:00
parent d15d4bdb84
commit 21e1b91abc
1 changed files with 53 additions and 2 deletions

View File

@ -9,18 +9,52 @@ module tasky.engine;
import eventy.engine : EvEngine = Engine;
import tasky.jobs : Descriptor;
import tristanable;
import std.socket : Socket;
import core.thread : Thread;
public final class Engine
public final class Engine : Thread
{
/**
* Tristanable sub-system
*/
private Manager tmanager;
/**
* Eventy sub-system
*/
private EvEngine evEngine;
this()
this(Socket socket)
{
/* Set the worker function */
super(&worker);
/* TODO: Check for exceptions */
/* Create a new event engine */
evEngine = new EvEngine();
evEngine.start();
/* TODO: Check for exceptions */
/* Create a new tristanable manager */
tmanager = new Manager(socket);
}
/**
* Worker thread function which checks the tristanable
* queues for whichever has messages on them and then
* dispatches a job-response for them via eventy
*/
private void worker()
{
while(true)
{
}
}
/**
* Register a Descriptor with tasky
*/
@ -31,5 +65,22 @@ public final class Engine
/* Add a signal handler that handles said descriptor ID */
evEngine.addSignalHandler(desc);
/* TODO: Tristanable queue addition here */
/* Create a new queue for this Job */
Queue tQueue = new Queue(desc.getDescriptorClass());
/* Add the Queue to tristanable */
tmanager.addQueue(tQueue);
}
unittest
{
/* FIXME: Don't pass in null */
Engine e = new Engine(null);
}
}