Package civitas.celestis.task.lifecycle
Interface Scheduler
- All Superinterfaces:
Module
- All Known Implementing Classes:
AtomicScheduler,SchedulerThread,SyncScheduler
A scheduler. Handles the registration and execution of tasks.
Scheduler can execute tasks on a regular basis. Scheduler are categorized
by two criteria: whether it is synchronous, and whether it is strict.
Synchronous schedulers only have one thread, (usually the scheduler itself) and thus can only execute tasks sequentially. On the other hand, asynchronous schedulers are capable of multithreaded operation.
Strict schedulers have no delay between each iteration, adhering to the interval of the tasks in a strict manner. Non-strict or lazy schedulers sleep after each iteration, which can help to avoid unnecessary iterations of looping through the list of tasks pointlessly. (since a task will only be executed after the interval of the task has passed)
Which implementation is used should vary between applications, selecting the appropriate implementation depending on the application's nature.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a task to this scheduler, instructing it to start executing it as soon as possible.voidregisterAsync(Iterable<? extends Task> tasks) Registers multiple tasks asynchronously to this scheduler, instructing it to distribute the tasks across multiple threads however it sees fit.voidregisterSync(Iterable<? extends Task> tasks) Registers multiple tasks synchronously to this scheduler, instructing it to put every provided task into a single thread to ensure sequential execution.voidunregister(Task task) Unregisters a task from this scheduler, instructing it to stop executing it.voidunregister(Iterable<? extends Task> tasks) Unregisters multiple tasks from this scheduler, instructing it to stop executing every task within the provided iterable object of tasks.Methods inherited from interface civitas.celestis.util.Module
initialize, interrupt, start, terminate
-
Method Details
-
register
Registers a task to this scheduler, instructing it to start executing it as soon as possible.- Parameters:
task- The task to register to this scheduler
-
registerSync
Registers multiple tasks synchronously to this scheduler, instructing it to put every provided task into a single thread to ensure sequential execution.- Parameters:
tasks- The iterable object containing the tasks to register
-
registerAsync
Registers multiple tasks asynchronously to this scheduler, instructing it to distribute the tasks across multiple threads however it sees fit. Sequential execution is not guaranteed, and this is equivalent to iteratively callingregister(Task)for each task.- Parameters:
tasks- The iterable object containing the tasks to register
-
unregister
Unregisters a task from this scheduler, instructing it to stop executing it.- Parameters:
task- The task to unregister from this scheduler
-
unregister
Unregisters multiple tasks from this scheduler, instructing it to stop executing every task within the provided iterable object of tasks.- Parameters:
tasks- The iterable object containing the tasks to unregister
-