Made register callable inside the mainloop
This commit is contained in:
parent
b23de9a3d4
commit
655d8d187b
|
|
@ -12,6 +12,7 @@ import mainloop.time.MainloopTimer;
|
||||||
public class MainloopManager
|
public class MainloopManager
|
||||||
{
|
{
|
||||||
protected ArrayList<MainloopTask> tasks;
|
protected ArrayList<MainloopTask> tasks;
|
||||||
|
protected ArrayList<MainloopTask> tasks_to_add = new ArrayList<MainloopTask>();
|
||||||
protected IMainloopEvent handler;
|
protected IMainloopEvent handler;
|
||||||
protected boolean running = false;
|
protected boolean running = false;
|
||||||
protected MainloopTimer timer;
|
protected MainloopTimer timer;
|
||||||
|
|
@ -54,6 +55,18 @@ public class MainloopManager
|
||||||
|
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
|
// Does the tasks to add array have content in it
|
||||||
|
if(tasks_to_add.size() > 0)
|
||||||
|
{
|
||||||
|
// Add all the tasks to add
|
||||||
|
for(MainloopTask task : tasks_to_add) {
|
||||||
|
tasks.add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the tasks to add array
|
||||||
|
tasks_to_add.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Loop over the tasks
|
// Loop over the tasks
|
||||||
for(Iterator<MainloopTask> i=tasks.iterator();i.hasNext();)
|
for(Iterator<MainloopTask> i=tasks.iterator();i.hasNext();)
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +86,7 @@ public class MainloopManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(IMainloopTask task) {
|
public void register(IMainloopTask task) {
|
||||||
tasks.add(new MainloopTask(task));
|
tasks_to_add.add(new MainloopTask(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue