mirror of https://github.com/deavmi/tasky.git
Fully implemented dispatcher
This commit is contained in:
parent
72082d8d23
commit
f9b2d24e8c
|
@ -5,6 +5,7 @@ import core.sync.mutex : Mutex;
|
||||||
import tristanable.manager;
|
import tristanable.manager;
|
||||||
import std.socket : Socket;
|
import std.socket : Socket;
|
||||||
import tristanable.queue : Queue;
|
import tristanable.queue : Queue;
|
||||||
|
import tristanable.queueitem;
|
||||||
import tristanable.encoding : DataMessage, encodeForSend;
|
import tristanable.encoding : DataMessage, encodeForSend;
|
||||||
import eventy;
|
import eventy;
|
||||||
|
|
||||||
|
@ -57,8 +58,11 @@ public final class TaskManager : Thread
|
||||||
/* If the job is fulfilled */
|
/* If the job is fulfilled */
|
||||||
if(job.isFulfilled())
|
if(job.isFulfilled())
|
||||||
{
|
{
|
||||||
/* Get the job's task */
|
/* Get the Event for dispatching */
|
||||||
Task jobTask = job.getTask();
|
Event dispatchEvent = job.getEventForDispatch();
|
||||||
|
|
||||||
|
/* Dispatch the event */
|
||||||
|
eventEngine.push(dispatchEvent);
|
||||||
|
|
||||||
/* Free the tristanable tag for this job */
|
/* Free the tristanable tag for this job */
|
||||||
job.complete();
|
job.complete();
|
||||||
|
@ -116,6 +120,18 @@ public final class TaskManager : Thread
|
||||||
return tEncoded;
|
return tEncoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Event getEventForDispatch()
|
||||||
|
{
|
||||||
|
/* Dequeue the data from the tristanable queue */
|
||||||
|
QueueItem queueItem = tristanableTag.dequeue();
|
||||||
|
byte[] receivedData = queueItem.getData();
|
||||||
|
|
||||||
|
/* Parse into Event (based on the Job's task type) and return */
|
||||||
|
Event eventToDispatch = task.getEvent(receivedData);
|
||||||
|
|
||||||
|
return eventToDispatch;
|
||||||
|
}
|
||||||
|
|
||||||
public bool isFulfilled()
|
public bool isFulfilled()
|
||||||
{
|
{
|
||||||
return tristanableTag.poll();
|
return tristanableTag.poll();
|
||||||
|
|
Loading…
Reference in New Issue