Add a simple task bus with console status messages.

This commit is contained in:
Aria 2023-05-06 03:37:01 -07:00
parent c6d83e67d5
commit ec58268a25
5 changed files with 142 additions and 2 deletions

View file

@ -0,0 +1,38 @@
package dev.zontreck.ariaslib.terminal;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import java.util.List;
import java.util.Stack;
public class TaskBus implements Runnable
{
public static Stack<Task> tasks = new Stack<>();
public static Task current = null;
@Override
public void run()
{
try{
if(TaskBus.current == null)
{
current = tasks.pop();
current.startTask();
}else {
if(current.isComplete())
{
current.stopTask();
current=null;
}
}
// Don't care about a empty stack exception. We'll just queue this task check back up
}catch(Exception e){}
}
public static void register()
{
DelayedExecutorService.getInstance().scheduleRepeating(new TaskBus(), 1);
}
}