All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ioc.commons.flowcontrol.taskcontroller.TaskController Maven / Gradle / Ivy

Go to download

This project defines a set of useful java interfaces for helping you in the definition of the structure of your developments in Java-projects which are designed using a Inversion-Of-Control (IOC) pattern. Useful for MVP-Pattern designs in applications coded on GWT, SWT, Android, etc.

There is a newer version: 1.2.1
Show newest version
package org.ioc.commons.flowcontrol.taskcontroller;

/**
 * The task controller is used to manage the execution of separated portion of
 * code depending on the invoked method.
 * 
 * @author Jesús Lunar Pérez
 * 
 */
public interface TaskController {
	/**
	 * Starts a task after a time.
	 * 
	 * @param delayMillis
	 *            Time delayed before starting the task.
	 * 
	 * @param task
	 *            The task to be executed.
	 * 
	 * @return Handler.
	 */
	TaskHandler scheduleDelayed(int delayMillis, Task task);

	/**
	 * Starts a task after a time and repeat it during this period until the
	 * repeating task returns false.
	 * 
	 * @param periodMillis
	 *            Time delayed before starting the task and period between each
	 *            repetition.
	 * 
	 * @param task
	 *            The task to be executed until its run() method returns false.
	 * 
	 * @return Handler.
	 */
	TaskHandler scheduleDelayed(int periodMillis, RepeatingTask task);

	/**
	 * Starts a task when system is idle.
	 * 
	 * @param task
	 *            The task to be executed.
	 * 
	 * @return Handler.
	 */
	TaskHandler scheduleIdle(Task task);

	/**
	 * Starts a task when system is idle, and will be repeated until the run()
	 * method returns false.
	 * 
	 * @param task
	 *            The task to be executed.
	 * @return Handler.
	 */
	TaskHandler scheduleIdle(RepeatingTask task);

	/**
	 * Starts a task JUST BEFORE system becomes idle. That is, the last task
	 * executed before the system is idle.
	 * 
	 * @param task
	 *            The task to be executed.
	 * 
	 * @return Handler.
	 */
	TaskHandler scheduleFinally(Task task);

	/**
	 * Starts a task JUST BEFORE system becomes idle and will be repeated until
	 * the run() method returns false.
	 * 
	 * @param task
	 *            The task to be executed.
	 * 
	 * @return Handler.
	 */
	TaskHandler scheduleFinally(RepeatingTask task);

	/**
	 * Runs a task asynchronously
	 * 
	 * @param task
	 *            The task to be executed.
	 * 
	 * @return Handler.
	 */
	TaskHandler runAsync(Task task);

	/**
	 * Number of pending tasks
	 * 
	 * @return Pending task count
	 */
	int getPendingTasks();

	/**
	 * Determines if there are some pending tasks on this controller.
	 * 
	 * @return true if {@link #getPendingTasks()} > 0; otherwise false
	 */
	boolean hasPendingTasks();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy