mirror of https://github.com/deavmi/tasky.git
Descriptor must override a method that takes in a TaskyEvent as those will only ever be created, this means you no longer need to do an annoying cast from Event to TaskyEvent
This commit is contained in:
parent
726ad57706
commit
8e35e282c1
|
@ -180,13 +180,12 @@ public final class Engine : Thread
|
|||
|
||||
/* Job type */
|
||||
Descriptor jobType = new class Descriptor {
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
import std.stdio : writeln;
|
||||
writeln("Event id ", e.id);
|
||||
|
||||
TaskyEvent eT = cast(TaskyEvent)e;
|
||||
string data = cast(string)eT.payload;
|
||||
string data = cast(string)e.payload;
|
||||
writeln(data);
|
||||
|
||||
if(cmp(data, "Hello 1") == 0)
|
||||
|
@ -206,15 +205,14 @@ public final class Engine : Thread
|
|||
|
||||
/* Job type */
|
||||
Descriptor jobType2 = new class Descriptor {
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
import std.stdio : writeln;
|
||||
writeln("Event id ", e.id);
|
||||
|
||||
writeln("OTHER event type");
|
||||
|
||||
TaskyEvent eT = cast(TaskyEvent)e;
|
||||
string data = cast(string)eT.payload;
|
||||
string data = cast(string)e.payload;
|
||||
writeln(data);
|
||||
// job2C++;
|
||||
// assert(cmp(cast(string)eT.payload, ""))
|
||||
|
|
|
@ -20,7 +20,12 @@ import std.string : cmp;
|
|||
import eventy.signal : Signal;
|
||||
import eventy.event : Event;
|
||||
|
||||
// <<<<<<< Updated upstream
|
||||
import std.conv : to;
|
||||
// =======
|
||||
|
||||
import tasky.engine : Engine, TaskyEvent;
|
||||
// >>>>>>> Stashed changes
|
||||
|
||||
/**
|
||||
* A Job to be scheduled
|
||||
|
@ -339,7 +344,7 @@ public abstract class Descriptor : Signal
|
|||
super(1);
|
||||
}
|
||||
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
writeln("Event id ", e.id);
|
||||
}
|
||||
|
@ -369,7 +374,7 @@ public abstract class Descriptor : Signal
|
|||
super(2);
|
||||
}
|
||||
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
writeln("Event id ", e.id);
|
||||
}
|
||||
|
@ -398,7 +403,7 @@ public abstract class Descriptor : Signal
|
|||
super(2);
|
||||
}
|
||||
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
writeln("Event id ", e.id);
|
||||
}
|
||||
|
@ -432,7 +437,7 @@ public abstract class Descriptor : Signal
|
|||
}
|
||||
|
||||
|
||||
public override void handler(Event e)
|
||||
public override void handler_TaskyEvent(TaskyEvent e)
|
||||
{
|
||||
writeln("Event id ", e.id);
|
||||
}
|
||||
|
@ -477,8 +482,24 @@ public abstract class Descriptor : Signal
|
|||
|
||||
/**
|
||||
* Override this to handle Event
|
||||
*
|
||||
* TODO: This should be final and non-abstract
|
||||
* and take in `Event e`, then the suer overrides
|
||||
* one that takes in a TaskyEvent, this handler
|
||||
* must call that one and THAT one must be abstract.
|
||||
*
|
||||
* This would make a lot more sense seeing how we
|
||||
* always want to pack data.
|
||||
*
|
||||
* TODO: Make this named _entry and other named handler
|
||||
*
|
||||
*/
|
||||
public abstract override void handler(Event e);
|
||||
public final override void handler(Event e)
|
||||
{
|
||||
handler_TaskyEvent(cast(TaskyEvent)e);
|
||||
}
|
||||
|
||||
public abstract void handler_TaskyEvent(TaskyEvent e);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue