diff --git a/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java b/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java index 64108f8de..5c49b524a 100644 --- a/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java +++ b/mirai-console/src/main/java/net/mamoe/mirai/console/scheduler/SchedulerTaskManager.java @@ -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 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; } } + diff --git a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/scheduler/SchedulerTask.kt b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/scheduler/SchedulerTask.kt index 7c2c6287c..7283b4317 100644 --- a/mirai-console/src/main/kotlin/net/mamoe/mirai/console/scheduler/SchedulerTask.kt +++ b/mirai-console/src/main/kotlin/net/mamoe/mirai/console/scheduler/SchedulerTask.kt @@ -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(定时任务) *