mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-16 21:58:01 +08:00
changed timer
This commit is contained in:
@@ -5,15 +5,13 @@ import component.Identifier;
|
||||
import component.IdentifierWrapper;
|
||||
import encoding.TLV;
|
||||
import encoding.VlIntException;
|
||||
import javafx.concurrent.Task;
|
||||
import logicface.CallbackInterface.*;
|
||||
import packet.*;
|
||||
import util.ConcurrentHelper;
|
||||
import util.TimeHelper;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
@@ -181,10 +179,20 @@ public class LogicFaceICN extends LogicFace {
|
||||
}
|
||||
}
|
||||
if(this.timeoutEventHeap.size()>0){
|
||||
// this.timer. todo: 什么鬼???
|
||||
this.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
dealWithTimeout();
|
||||
}
|
||||
},this.timeoutEventHeap.peek().timeoutTime-currentTime);
|
||||
this.recentExpireTime=this.timeoutEventHeap.peek().timeoutTime;
|
||||
}else{
|
||||
// this.timer. todo: 什么鬼???
|
||||
this.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
dealWithTimeout();
|
||||
}
|
||||
},500000);
|
||||
this.recentExpireTime=currentTime+500000;
|
||||
}
|
||||
this.timeoutEventHeapLock.unlock();
|
||||
@@ -193,21 +201,27 @@ public class LogicFaceICN extends LogicFace {
|
||||
/**
|
||||
* 等待 timer超时,触发调用dealWithTimeout函数
|
||||
*/
|
||||
private void detectTimeout(){
|
||||
while (true){
|
||||
// this.timer.C // todo: 啥玩意儿啊??
|
||||
this.dealWithTimeout();
|
||||
}
|
||||
}
|
||||
// private void detectTimeout(){
|
||||
// while (true){
|
||||
// // this.timer.C
|
||||
// this.dealWithTimeout();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 在 processEvent之前先初始化一些东西主要 包括初始化PIT表,和将定时器启动起来
|
||||
*/
|
||||
public void initBeforeProcessEvent(){
|
||||
this.mPit=new HashMap<>();
|
||||
this.timer=new Timer(); // todo: timer???
|
||||
this.timer=new Timer();
|
||||
this.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
dealWithTimeout();
|
||||
}
|
||||
},500000);
|
||||
this.recentExpireTime=TimeHelper.getTimestampMS()+500000;
|
||||
ConcurrentHelper.doConcurrent(() -> detectTimeout());
|
||||
// ConcurrentHelper.doConcurrent(() -> detectTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +275,12 @@ public class LogicFaceICN extends LogicFace {
|
||||
if(this.timeoutEventHeap.peek().timeoutTime<this.recentExpireTime){
|
||||
long durationMs=this.timeoutEventHeap.peek().timeoutTime-TimeHelper.getTimestampMS();
|
||||
this.recentExpireTime=this.timeoutEventHeap.peek().timeoutTime;
|
||||
// todo: this.timer.Reset
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
dealWithTimeout();
|
||||
}
|
||||
}, durationMs);
|
||||
}
|
||||
this.timeoutEventHeapLock.unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user