You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
671 B
38 lines
671 B
package mightypork.rogue.bus.events;
|
|
|
|
|
|
import mightypork.utils.control.bus.Event;
|
|
import mightypork.utils.control.bus.SingularEvent;
|
|
|
|
|
|
/**
|
|
* Request to execute given {@link Runnable} in main loop.
|
|
*
|
|
* @author MightyPork
|
|
*/
|
|
public class MainLoopTaskRequest implements Event<MainLoopTaskRequest.Listener>, SingularEvent {
|
|
|
|
private final Runnable task;
|
|
|
|
|
|
public MainLoopTaskRequest(Runnable task) {
|
|
this.task = task;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void handleBy(Listener handler)
|
|
{
|
|
handler.queueTask(task);
|
|
}
|
|
|
|
public interface Listener {
|
|
|
|
/**
|
|
* Perform the requested action
|
|
*
|
|
* @param request
|
|
*/
|
|
public void queueTask(Runnable request);
|
|
}
|
|
}
|
|
|