1
This commit is contained in:
parent
7e25038d3e
commit
fa3d6d840b
73
Timer.java
73
Timer.java
@ -2,19 +2,6 @@ package a6;
|
||||
|
||||
public class Timer {
|
||||
|
||||
public class TimerList
|
||||
{
|
||||
private ListHead entry = new ListHead();
|
||||
private ListHead attachEntry;
|
||||
private int timerType = 0;
|
||||
private int milli_seconds = 0;
|
||||
private long expires = 0;
|
||||
|
||||
private ITimerFunc timerFunc;
|
||||
private ITimerAfterFunc timerAfterFunc;
|
||||
private XParams param;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ITimerFunc
|
||||
{
|
||||
@ -27,11 +14,45 @@ public class Timer {
|
||||
public void OnTimerAfter(XParams param);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IGetTickCountFunc
|
||||
{
|
||||
public long GetTickCount(Object context);
|
||||
}
|
||||
|
||||
public class TimerList
|
||||
{
|
||||
private ListHead entry = new ListHead();
|
||||
private ListHead attachEntry;
|
||||
private int timerType = 0;
|
||||
private int milli_seconds = 0;
|
||||
private long expires = 0;
|
||||
|
||||
private ITimerFunc timerFunc;
|
||||
private ITimerAfterFunc timerAfterFunc;
|
||||
private XParams param;
|
||||
|
||||
private void initTimerList(Timer timer, int timer_type, int milli_seconds,
|
||||
XParams param, ITimerFunc timerFunc, ITimerAfterFunc afterFunc)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int freeTimerNum = 0;
|
||||
private ListHead freeTimer = new ListHead();
|
||||
private TimerList runningTimer;
|
||||
private long timerTick = 0;
|
||||
private IGetTickCountFunc getTickCount;
|
||||
private Object content;
|
||||
private int gcTime = 0;
|
||||
private int cacheTimerNum = 0;
|
||||
|
||||
public void init() {
|
||||
|
||||
public void init(IGetTickCountFunc func, Object content, int gc_time, int cache_timer_num) {
|
||||
this.getTickCount = func;
|
||||
this.content = content;
|
||||
this.gcTime = gc_time;
|
||||
this.cacheTimerNum = cache_timer_num;
|
||||
}
|
||||
|
||||
public void unInit() {
|
||||
@ -43,30 +64,40 @@ public class Timer {
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimer(int expire_time, XParams param, ITimerFunc timer_func) {
|
||||
return null;
|
||||
return addDeadLineTimer(expire_time, param, timer_func, null);
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimer(int expire_time, XParams param, ITimerFunc timer_func,
|
||||
ITimerAfterFunc after_func) {
|
||||
return null;
|
||||
TimerList timer = newTimerList();
|
||||
timer.initTimerList(this, 0, expire_time, param, timer_func, after_func);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimerAndAttach(int expire_time, XParams param, ITimerFunc timer_func,
|
||||
TimerAttacher timer_attacher) {
|
||||
return null;
|
||||
return addDeadLineTimerAndAttach(expire_time, param, timer_func, timer_attacher, null);
|
||||
}
|
||||
|
||||
public TimerList addDeadLineTimerAndAttach(int expire_time, XParams param, ITimerFunc timer_func,
|
||||
TimerAttacher timer_attacher, ITimerAfterFunc after_func) {
|
||||
return null;
|
||||
TimerList timer = addDeadLineTimer(expire_time, param, timer_func, after_func);
|
||||
timer_attacher.addTimer(timer.attachEntry);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public TimerList addRepeatTimer(int expire_time, XParams param, ITimerFunc timer_func) {
|
||||
return null;
|
||||
TimerList timer = newTimerList();
|
||||
timer.initTimerList(this, 1, expire_time, param, timer_func, null);
|
||||
modifyTimer(timer, expire_time);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public TimerList addFixedTimer(int expire_time, XParams param, ITimerFunc timer_func) {
|
||||
return null;
|
||||
TimerList timer = newTimerList();
|
||||
timer.initTimerList(this, 2, expire_time, param, timer_func, null);
|
||||
modifyTimer(timer, expire_time);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public void modifyTimer(TimerList timer_list, int expire_time) {
|
||||
|
@ -2,6 +2,10 @@ package a6;
|
||||
|
||||
public class TimerAttacher {
|
||||
|
||||
public void addTimer(ListHead node) {
|
||||
|
||||
}
|
||||
|
||||
public void clearTimer() {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user