Package org.omegazero.common.event
Class TaskScheduler.TimerTask
java.lang.Object
org.omegazero.common.event.task.AbstractTask
org.omegazero.common.event.task.LambdaTask
org.omegazero.common.event.TaskScheduler.TimerTask
- All Implemented Interfaces:
Comparable<Task>,Runnable,Task
- Enclosing class:
TaskScheduler
Represents a task managed by a
TaskScheduler.-
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Cancels this task.daemon()Marks this task as a daemon task.longgetId()Returns theTaskScheduler-instance-wide unique ID of thisTaskScheduler.TimerTask.longReturns the interval in nanoseconds between running this task.longgetTime()Returns the absolute time in nanoseconds when this task is scheduled to run.booleanReturnstrueif this task is canceled.booleanisDaemon()Returnstrueif this task was defined as a daemon task.undaemon()Marks this task as a non-daemon task.Methods inherited from class org.omegazero.common.event.task.LambdaTask
destroy, executeMethods inherited from class org.omegazero.common.event.task.AbstractTask
getPriority, run
-
Method Details
-
cancel
public boolean cancel()Cancels this task. Equivalent to a call to:taskScheduler.
whereclear(this)taskScheduleris theTaskSchedulerthat created thisTaskScheduler.TimerTask.- Returns:
trueif the task was found and successfully canceled- Since:
- 2.6
- See Also:
-
daemon
Marks this task as a daemon task. If a task is a daemon task, it will not prevent theTaskSchedulerfrom exiting.- Returns:
- This instance
- See Also:
-
undaemon
Marks this task as a non-daemon task. Queued non-daemon tasks prevent theTaskSchedulerfrom exiting.- Returns:
- This instance
- See Also:
-
getId
public long getId()Returns theTaskScheduler-instance-wide unique ID of thisTaskScheduler.TimerTask.- Returns:
- The ID
-
getTime
public long getTime()Returns the absolute time in nanoseconds when this task is scheduled to run.- Returns:
- The absolute time
-
getPeriod
public long getPeriod()Returns the interval in nanoseconds between running this task. This value is 0 for a one-time task.- Returns:
- The interval period
-
isDaemon
public boolean isDaemon()Returnstrueif this task was defined as a daemon task.- Returns:
- Whether this task was defined as a daemon task
- See Also:
-
isCanceled
public boolean isCanceled()Returnstrueif this task is canceled.- Returns:
- Whether this task is canceled
-