Removed deprecated `setSleep(Duration)`

Added `getConfig()/setConfig(EngineSettings)` to retrieve and update the configuration of the Engine on the fly

Privated `getTypes()` method for now as it is not implemented yet
This commit is contained in:
Tristan B. Velloza Kildaire 2022-11-26 17:23:40 +02:00
parent be44514a51
commit 3603c567e8
1 changed files with 68 additions and 63 deletions

View File

@ -196,30 +196,26 @@ public final class Engine : Thread
}
/**
* Set the event loop sleep time
* Returns the current configuration paremeters being
* used by the engine
*
* The load average will sky rocket if it is 0,
* which is just because it is calculated on how
* full the run queue is, length but also over time
* and even just one task continousy in it will
* make the average high
*
* Reason why it's always runnable is the process
* (the "thread") is a tight loop with no sleeps
* that would dequeue it from the run queue and/or
* no I/O system calls that would put it into the
* waiting queue
* Returns: The EngineSettings struct
*/
public void setSleep(Duration time)
public EngineSettings getConfig()
{
// sleepTime = time;
return settings;
}
/**
* Adds the given Signal handler
* Updates the current configuration of the engine
*
* @param e the Signal handler to add
* Params:
* newSettings = The new EngineSettings struct to use
*/
public void setConfig(EngineSettings newSettings)
{
this.settings = newSettings;
}
/**
* Attaches a new signal handler to the engine
@ -383,6 +379,9 @@ public final class Engine : Thread
/**
* Removes a thread from the thread store
*
* Params:
* t = the thread to remove
*/
private void removeThread(DispatchWrapper t)
{
@ -425,12 +424,13 @@ public final class Engine : Thread
}
/**
* returns all signal(s) responsible for
* handling the type of Event provided
* Returns all the signal handlers responsible
* for handling the type of Event provided
*
* @param e the Event type to match to
* @returns Signal[] the list of signal
* handlers that handle event e
* Params:
* e = the Event type to match to
* Returns: A Signal[] containing each handler
* registered to handle type <code>e</code>
*/
public Signal[] getSignalsForEvent(Event e)
{
@ -458,6 +458,7 @@ public final class Engine : Thread
/**
* Checks if there is a signal handler that handles
* the given event id
*
* Params:
* id = the event ID to check
* Returns:
@ -468,10 +469,11 @@ public final class Engine : Thread
}
/**
* push(Event e)
* Pushes the given Event into the engine
* for eventual dispatch
*
* Provided an Event, `e`, this will enqueue the event
* to
* Params:
* e = the event to push
*/
public void push(Event e)
{
@ -486,11 +488,14 @@ public final class Engine : Thread
/**
* Creates a new queue with the given id
* and then adds it
* and then adds it.
*
* @param id the id of the new queue to add
* @throws EventyException if a queue with
* the given id already exists
* Throws EventyException if the id is already
* in use by another queue
*
* Params:
* id = the id of the neq eueue to create
* Throws: EventyException
*/
public void addQueue(ulong id)
{
@ -516,13 +521,13 @@ public final class Engine : Thread
}
/**
* Given an id, this will return
* the Queue associated with said
* id
* Given an if, this will return the Queue
* associated with said id
*
* @param id the id of the Queue
* @returns The Queue if found but
* null otherwise
* Params:
* id = the id of the Queue
* Returns: The Queue if found, otherwise
* <code>null</code>
*/
public Queue findQueue(ulong id)
{
@ -547,7 +552,7 @@ public final class Engine : Thread
}
/* TODO: Add coumentation */
public ulong[] getTypes()
private ulong[] getTypes()
{
/* TODO: Implement me */
return null;