Skip to content

Commit

Permalink
Update WheelTimer.java
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Dec 26, 2024
1 parent bae784a commit 90e8acc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rxlib/src/main/java/org/rx/core/WheelTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.netty.util.internal.ThreadLocalRandom;
import lombok.*;
import org.rx.bean.$;
import org.rx.bean.DateTime;
import org.rx.bean.FlagsEnum;
import org.rx.util.function.Action;
import org.rx.util.function.Func;
Expand Down Expand Up @@ -218,6 +219,14 @@ public void run(Timeout timeout) throws Exception {

static final long TICK_DURATION = 100;
static final Map<Object, TimeoutFuture> holder = new ConcurrentHashMap<>();

public static LongUnaryOperator dailyOperator(@NonNull Func<String> timeFn) {
return d -> {
long delay = DateTime.now().setTimePart(timeFn.get()).getTime() - System.currentTimeMillis();
return delay > 0 ? delay : Constants.ONE_DAY_TOTAL_SECONDS * 1000 + delay;
};
}

final ExecutorService executor;
final HashedWheelTimer timer = new HashedWheelTimer(ThreadPool.newThreadFactory("TIMER", Thread.NORM_PRIORITY), TICK_DURATION, TimeUnit.MILLISECONDS);
final EmptyTimeout nonTask = new EmptyTimeout();
Expand Down

0 comments on commit 90e8acc

Please sign in to comment.