Package com.mewna.catnip.util.scheduler
Interface TaskScheduler
- All Superinterfaces:
Entity
,RequiresCatnip
- All Known Implementing Classes:
AbstractTaskScheduler
,RxTaskScheduler
A basic task scheduler to replace vert.x's setTimer() and setPeriodic(). The
default implementation is
RxTaskScheduler
, which is a basic wrapper
over Observable.timer(long, TimeUnit)
and
Observable.interval(long, TimeUnit)
.- Since:
- 7/29/19.
- Author:
- amy
-
Method Summary
Methods inherited from interface com.mewna.catnip.entity.RequiresCatnip
catnip
-
Method Details
-
setTimer
Schedules a new task to be run in the future.- Parameters:
ms
- Delay, in milliseconds, before the task is run.task
- The task to be run.- Returns:
- The id of the task to be run. Used for cancellations.
-
setInterval
Schedules a new task to be run on an interval.- Parameters:
ms
- Interval, in milliseconds, between task runs.task
- The task to be run.- Returns:
- The id of the task to be run. Used for cancellations.
-
cancel
boolean cancel(@Nonnegative long id) Cancels the task with the supplied id.- Parameters:
id
- The id of the task to cancel.- Returns:
true
if the task was successfully cancelled,false
otherwise.
-