Package civitas.celestis.task
Interface Task
- All Known Implementing Classes:
DelayedTask
public interface Task
Defines the contract of a task which can be registered and executed
by a scheduler. Tasks are provided with a delta each execution, which is
the amount of time between the last execution and now in milliseconds.
All methods excluding execute(long) are default, making this
interface declarable by use of a lambda expression. This is an intended feature,
and this will continue to be the only abstract method in the future.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default interval of a task in milliseconds. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(long delta) Executes this task.default longinterval()Returns the interval of this task.default voidonRegistered(Scheduler scheduler) Called upon registration to a scheduler.default voidonUnregistered(Scheduler scheduler) Called upon unregistration from a scheduler.
-
Field Details
-
DEFAULT_INTERVAL
static final long DEFAULT_INTERVALThe default interval of a task in milliseconds.- See Also:
-
-
Method Details
-
execute
void execute(long delta) Executes this task.- Parameters:
delta- The duration between the last execution and now in milliseconds
-
interval
default long interval()Returns the interval of this task.- Returns:
- The interval of this task in milliseconds
-
onRegistered
Called upon registration to a scheduler.- Parameters:
scheduler- The scheduler this task was registered to
-
onUnregistered
Called upon unregistration from a scheduler.- Parameters:
scheduler- The scheduler this task was unregistered from
-