Removed commented out code

Moved testing imports within each unit test

Added a new unit test which tests the yield-based HoldOffMode

Neteaned up imports
This commit is contained in:
Tristan B. Velloza Kildaire 2022-11-26 17:31:03 +02:00
parent 59d0253b61
commit a501de15d3
1 changed files with 51 additions and 58 deletions

View File

@ -4,25 +4,16 @@ import eventy.queues : Queue;
import eventy.signal : Signal; import eventy.signal : Signal;
import eventy.event : Event; import eventy.event : Event;
import eventy.config; import eventy.config;
import eventy.exceptions;
import std.container.dlist; import std.container.dlist;
import core.sync.mutex : Mutex; import core.sync.mutex : Mutex;
import core.thread : Thread, dur, Duration; import core.thread : Thread, dur, Duration;
import eventy.exceptions;
import std.stdio;
// /* TODO: Move elsewhere, this thing thinks it's a delegate in the unit test, idk why */
// private void runner(Event e)
// {
// import std.stdio;
// writeln("Running event", e.id);
// }
unittest unittest
{ {
import std.stdio;
Engine engine = new Engine(); Engine engine = new Engine();
engine.start(); engine.start();
@ -75,64 +66,66 @@ unittest
/* TODO: Before shutting down, actually test it out (i.e. all events ran) */ /* TODO: Before shutting down, actually test it out (i.e. all events ran) */
engine.shutdown(); engine.shutdown();
} }
// unittest unittest
// { {
// EngineSettings customSettings = {holdOffMode: HoldOffMode.YIELD}; import std.stdio;
// Engine engine = new Engine(customSettings);
// engine.start();
// /** EngineSettings customSettings = {holdOffMode: HoldOffMode.YIELD};
// * Let the event engine know what typeIDs are Engine engine = new Engine(customSettings);
// * allowed to be queued engine.start();
// */
// engine.addQueue(1);
// engine.addQueue(2);
// /** /**
// * Create a new Signal Handler that will handles * Let the event engine know what typeIDs are
// * event types `1` and `2` with the given `handler()` * allowed to be queued
// * function */
// */ engine.addQueue(1);
// class SignalHandler1 : Signal engine.addQueue(2);
// {
// this()
// {
// super([1, 2]);
// }
// public override void handler(Event e) /**
// { * Create a new Signal Handler that will handles
// import std.stdio; * event types `1` and `2` with the given `handler()`
* function
*/
class SignalHandler1 : Signal
{
this()
{
super([1, 2]);
}
// writeln("Running event", e.id); public override void handler(Event e)
// } {
// } import std.stdio;
// /** writeln("Running event", e.id);
// * Tell the event engine that I want to register }
// * the following handler for its queues `1` and `2` }
// */
// Signal j = new SignalHandler1();
// engine.addSignalHandler(j);
// Event eTest = new Event(1); /**
// engine.push(eTest); * Tell the event engine that I want to register
* the following handler for its queues `1` and `2`
*/
Signal j = new SignalHandler1();
engine.addSignalHandler(j);
// eTest = new Event(2); Event eTest = new Event(1);
// engine.push(eTest); engine.push(eTest);
// Thread.sleep(dur!("seconds")(2)); eTest = new Event(2);
// engine.push(eTest); engine.push(eTest);
// writeln("done with main thread code"); Thread.sleep(dur!("seconds")(2));
engine.push(eTest);
// /* TODO: Before shutting down, actually test it out (i.e. all events ran) */ writeln("done with main thread code");
// engine.shutdown();
// } while(engine.hasPendingEvents()) {}
/* TODO: Before shutting down, actually test it out (i.e. all events ran) */
engine.shutdown();
}
/** /**
* Engine * Engine