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 TypeMethodDescriptionboolean
cancel()
Cancels this task.daemon()
Marks this task as a daemon task.long
getId()
Returns theTaskScheduler
-instance-wide unique ID of thisTaskScheduler.TimerTask
.long
Returns the interval in nanoseconds between running this task.long
getTime()
Returns the absolute time in nanoseconds when this task is scheduled to run.boolean
Returnstrue
if this task is canceled.boolean
isDaemon()
Returnstrue
if 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, execute
Methods 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)taskScheduler
is theTaskScheduler
that created thisTaskScheduler.TimerTask
.- Returns:
true
if 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 theTaskScheduler
from exiting.- Returns:
- This instance
- See Also:
-
undaemon
Marks this task as a non-daemon task. Queued non-daemon tasks prevent theTaskScheduler
from 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()Returnstrue
if this task was defined as a daemon task.- Returns:
- Whether this task was defined as a daemon task
- See Also:
-
isCanceled
public boolean isCanceled()Returnstrue
if this task is canceled.- Returns:
- Whether this task is canceled
-