mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-07 16:40:43 +08:00
Improve Java Scheduler Task
This commit is contained in:
parent
8adeb3f04d
commit
20c5b5334d
@ -5,8 +5,32 @@ package net.mamoe.mirai.console.scheduler;
|
||||
* 使用kt实现, java的API
|
||||
*/
|
||||
|
||||
/**
|
||||
* PluginScheduler.RepeatTaskReceipt repeatTaskReceipt = this.getScheduler().repeat(() -> {
|
||||
* getLogger().info("I repeat");
|
||||
* },100);
|
||||
*
|
||||
*
|
||||
* this.getScheduler().delay(() -> {
|
||||
* repeatTaskReceipt.setCancelled(true);
|
||||
* },10000);
|
||||
*
|
||||
*
|
||||
* Future<String> future = this.getScheduler().async(() -> {
|
||||
* //do some task
|
||||
* return "success";
|
||||
* });
|
||||
*
|
||||
* try {
|
||||
* getLogger().info(future.get());
|
||||
* } catch (InterruptedException | ExecutionException e) {
|
||||
* e.printStackTrace();
|
||||
* }
|
||||
*/
|
||||
|
||||
public class SchedulerTaskManager {
|
||||
public static SchedulerTaskManagerInstance getInstance(){
|
||||
return SchedulerTaskManagerInstance.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class PluginScheduler(_coroutineContext: CoroutineContext) :CoroutineScope{
|
||||
override val coroutineContext: CoroutineContext = SupervisorJob() + _coroutineContext
|
||||
|
||||
|
||||
data class RepeatTaskReceipt(@Volatile var cancelled:Boolean = false)
|
||||
class RepeatTaskReceipt(@Volatile var cancelled:Boolean = false)
|
||||
/**
|
||||
* 新增一个Repeat Task(定时任务)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user