Package com.dianxin.tori.base.scheduler
Interface Scheduler
- All Known Implementing Classes:
SchedulerImpl
public interface Scheduler
Task scheduling management interface integrated with
ExecutorManager.
Uses a single dedicated clock thread to count down time offsets and subsequently dispatches execution payloads to either the CPU thread pool or the I/O thread pool.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancelTask(int taskId) Cancels an active or scheduled task matching the unique task ID.Executes a task immediately on the primary CPU-bound thread pool.runTaskAsync(Runnable runnable) Executes a task immediately on the asynchronous I/O-bound thread pool.runTaskLater(Runnable runnable, long delay, TimeUnit unit) Schedules a task to execute after a specified delay on the CPU thread pool.runTaskLaterAsync(Runnable runnable, long delay, TimeUnit unit) Schedules a task to execute asynchronously after a specified delay on the I/O thread pool.runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit) Schedules a repeated task to execute on the CPU thread pool.runTaskTimerAsync(Runnable runnable, long delay, long period, TimeUnit unit) Schedules a repeated task to execute asynchronously on the I/O thread pool.voidshutdown()Cancels all currently scheduled tasks and releases underlying thread pool resources.
-
Method Details
-
runTask
Executes a task immediately on the primary CPU-bound thread pool.- Parameters:
runnable- the task logic to execute- Returns:
- a tracked
Taskinstance
-
runTaskAsync
Executes a task immediately on the asynchronous I/O-bound thread pool.- Parameters:
runnable- the task logic to execute- Returns:
- a tracked
Taskinstance
-
runTaskLater
Schedules a task to execute after a specified delay on the CPU thread pool.- Parameters:
runnable- the task logic to executedelay- the time to wait before executingunit- the time unit of the delay parameter- Returns:
- a tracked
Taskinstance
-
runTaskLaterAsync
Schedules a task to execute asynchronously after a specified delay on the I/O thread pool.- Parameters:
runnable- the task logic to executedelay- the time to wait before executingunit- the time unit of the delay parameter- Returns:
- a tracked
Taskinstance
-
runTaskTimer
Schedules a repeated task to execute on the CPU thread pool.- Parameters:
runnable- the task logic to executedelay- the time to wait before the first executionperiod- the interval between successive executionsunit- the time unit of the delay and period parameters- Returns:
- a tracked
Taskinstance
-
runTaskTimerAsync
Schedules a repeated task to execute asynchronously on the I/O thread pool.- Parameters:
runnable- the task logic to executedelay- the time to wait before the first executionperiod- the interval between successive executionsunit- the time unit of the delay and period parameters- Returns:
- a tracked
Taskinstance
-
cancelTask
void cancelTask(int taskId) Cancels an active or scheduled task matching the unique task ID.- Parameters:
taskId- the unique identifier of the target task
-
shutdown
void shutdown()Cancels all currently scheduled tasks and releases underlying thread pool resources.
-