mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-18 02:59:57 +00:00
perf[scheduler]: 删除不必要的方法
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
|
||||
package com.zfoo.scheduler.manager;
|
||||
|
||||
import com.zfoo.protocol.collection.CollectionUtils;
|
||||
import com.zfoo.scheduler.SchedulerContext;
|
||||
import com.zfoo.scheduler.model.vo.SchedulerDefinition;
|
||||
import com.zfoo.scheduler.timeWheelUtils.Timer;
|
||||
@@ -22,8 +21,6 @@ import com.zfoo.scheduler.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -98,22 +95,6 @@ public abstract class SchedulerBus {
|
||||
}, delay, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* cron表达式执行的任务
|
||||
*/
|
||||
public static void scheduleCron(Runnable runnable, String cron) {
|
||||
if (SchedulerContext.isStop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SchedulerDefinition scheduler = SchedulerDefinition.valueOf(cron, runnable);
|
||||
var timerTask = new TimerTask(scheduler.getTriggerTimestamp(), () -> {
|
||||
scheduler.getScheduler().invoke();
|
||||
refreshTask(scheduler);
|
||||
});
|
||||
timer.addTask(timerTask);
|
||||
}
|
||||
|
||||
public static void refreshTask(SchedulerDefinition schedulerDefinition) {
|
||||
var timestamp = TimeUtils.currentTimeMillis();
|
||||
var nextTriggerTimestamp = TimeUtils.getNextTimestampByCronExpression(schedulerDefinition.getCronExpression(), timestamp);
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class IdUtils {
|
||||
private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* 本地int的id,如果达到最大值则重新从最小值重新计算
|
||||
* 获取本地int的唯一id,如果达到最大值则重新从最小值重新计算,线程安全
|
||||
*/
|
||||
public static int getLocalIntId() {
|
||||
return ATOMIC_INTEGER.incrementAndGet();
|
||||
|
||||
Reference in New Issue
Block a user