Add a simple task bus with console status messages.
This commit is contained in:
parent
c6d83e67d5
commit
ec58268a25
5 changed files with 142 additions and 2 deletions
38
src/main/java/dev/zontreck/ariaslib/terminal/TaskBus.java
Normal file
38
src/main/java/dev/zontreck/ariaslib/terminal/TaskBus.java
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue