This commit is contained in:
Looly
2023-04-12 01:22:54 +08:00
parent d2e5155ac5
commit a96a95c988
216 changed files with 480 additions and 480 deletions

View File

@@ -54,13 +54,13 @@ public class CronTimer extends Thread implements Serializable {
long thisTime = System.currentTimeMillis();
long nextTime;
long sleep;
while(! isStop){
while(!isStop){
//下一时间计算是按照上一个执行点开始时间计算的
//此处除以定时单位是为了清零单位以下部分,例如单位是分则秒和毫秒清零
nextTime = ((thisTime / timerUnit) + 1) * timerUnit;
sleep = nextTime - System.currentTimeMillis();
if(isValidSleepMillis(sleep, timerUnit)){
if (! ThreadUtil.safeSleep(sleep)) {
if (!ThreadUtil.safeSleep(sleep)) {
//等待直到下一个时间点如果被中断直接退出Timer
break;
}

View File

@@ -463,7 +463,7 @@ public class Scheduler implements Serializable {
public Scheduler stop(final boolean clearTasks) {
lock.lock();
try {
if (! started) {
if (!started) {
throw new IllegalStateException("Scheduler not started !");
}

View File

@@ -162,7 +162,7 @@ public class CronPattern {
*/
public Calendar nextMatchAfter(final Calendar calendar) {
Calendar next = nextMatchAfter(PatternUtil.getFields(calendar, true), calendar.getTimeZone());
if (! match(next, true)) {
if (!match(next, true)) {
next.set(Calendar.DAY_OF_MONTH, next.get(Calendar.DAY_OF_MONTH) + 1);
next = CalendarUtil.beginOfDay(next);
return nextMatchAfter(next);

View File

@@ -171,7 +171,7 @@ public class PartParser {
if (value.length() <= 2) {
//根据步进的第一个数字确定起始时间,类似于 12/3则从12秒、分等开始
int minValue = part.getMin();
if (! isMatchAllStr(value)) {
if (!isMatchAllStr(value)) {
minValue = Math.max(minValue, parseNumber(value));
} else {
//在全匹配模式下如果步进不存在表示步进为1

View File

@@ -70,7 +70,7 @@ public class SystemTimer {
bossThreadPool = ThreadUtil.newSingleExecutor();
bossThreadPool.submit(() -> {
while (true) {
if(! advanceClock()){
if(!advanceClock()){
break;
}
}
@@ -92,7 +92,7 @@ public class SystemTimer {
*/
public void addTask(final TimerTask timerTask) {
//添加失败任务直接执行
if (! timeWheel.addTask(timerTask)) {
if (!timeWheel.addTask(timerTask)) {
ThreadUtil.execAsync(timerTask.getTask());
}
}

View File

@@ -105,7 +105,7 @@ public class TimerTaskList implements Delayed {
*/
public synchronized void flush(final Consumer<TimerTask> flush) {
TimerTask timerTask = root.next;
while (! timerTask.equals(root)) {
while (!timerTask.equals(root)) {
this.removeTask(timerTask);
flush.accept(timerTask);
timerTask = root.next;