Package top.focess.qq.api.schedule
Interface Scheduler
-
public interface SchedulerUsed to schedule task
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcancelAll()Cancel all the tasksvoidclose()Close this schedulervoidcloseNow()Close this scheduler even if there are tasks runningStringgetName()Get the name of the schedulerPlugingetPlugin()Get the pluginbooleanisClosed()Indicate whether this scheduler is closed or notdefault Taskrun(Runnable runnable)Run a task nowTaskrun(Runnable runnable, java.time.Duration delay)Run a task laterTaskrunTimer(Runnable runnable, java.time.Duration delay, java.time.Duration period)Run a task timerdefault <V> Callback<V>submit(Callable<V> callable)Submit a task now<V> Callback<V>submit(Callable<V> callable, java.time.Duration delay)Submit a task later
-
-
-
Method Detail
-
run
default Task run(Runnable runnable)
Run a task now- Parameters:
runnable- the task- Returns:
- the wrapped task
- Throws:
SchedulerClosedException- if this scheduler is closed
-
run
Task run(Runnable runnable, java.time.Duration delay)
Run a task later- Parameters:
runnable- the taskdelay- the delay- Returns:
- the wrapped task
- Throws:
SchedulerClosedException- if this scheduler is closed
-
runTimer
Task runTimer(Runnable runnable, java.time.Duration delay, java.time.Duration period)
Run a task timer- Parameters:
runnable- the taskdelay- the delayperiod- the period- Returns:
- the wrapped task
- Throws:
SchedulerClosedException- if this scheduler is closed
-
submit
default <V> Callback<V> submit(Callable<V> callable)
Submit a task now- Type Parameters:
V- the return type- Parameters:
callable- the task- Returns:
- the wrapped callback
- Throws:
SchedulerClosedException- if this scheduler is closed
-
submit
<V> Callback<V> submit(Callable<V> callable, java.time.Duration delay)
Submit a task later- Type Parameters:
V- the return type- Parameters:
callable- the taskdelay- the delay- Returns:
- the wrapped callback
- Throws:
SchedulerClosedException- if this scheduler is closed
-
cancelAll
void cancelAll()
Cancel all the tasks
-
getName
String getName()
Get the name of the scheduler- Returns:
- the name of the scheduler
-
getPlugin
Plugin getPlugin()
Get the plugin- Returns:
- the plugin
-
close
void close()
Close this scheduler
-
isClosed
boolean isClosed()
Indicate whether this scheduler is closed or not- Returns:
- true if this scheduler is closed, false otherwise
-
closeNow
void closeNow()
Close this scheduler even if there are tasks running
-
-