public class TimingWheel extends Object
Constructor and Description |
---|
TimingWheel(long tickMs,
int wheelSize,
Consumer<TimerTaskList> consumer)
构造
|
TimingWheel(long tickMs,
int wheelSize,
long currentTime,
Consumer<TimerTaskList> consumer)
构造
|
Modifier and Type | Method and Description |
---|---|
boolean |
addTask(TimerTask timerTask)
添加任务到时间轮
|
void |
advanceClock(long timestamp)
推进时间
|
public TimingWheel(long tickMs, int wheelSize, Consumer<TimerTaskList> consumer)
tickMs
- 一个时间槽的范围,单位毫秒wheelSize
- 时间轮大小consumer
- 任务处理器public TimingWheel(long tickMs, int wheelSize, long currentTime, Consumer<TimerTaskList> consumer)
tickMs
- 一个时间槽的范围,单位毫秒wheelSize
- 时间轮大小currentTime
- 当前时间consumer
- 任务处理器public boolean addTask(TimerTask timerTask)
timerTask
- 任务public void advanceClock(long timestamp)
timestamp
- 推进的时间Copyright © 2024. All rights reserved.