/** 测试暂停 */ public void testPause(int time) { Ctrl.print("测试暂停"); _resumeTime = Ctrl.getTimer() + time; _testPause = true; }
/// <summary> /// 发送ping消息 /// </summary> private void sendPingRequest() { if (_pingSending) { _ping = -1; } _pingSending = true; _sendPingTime = Ctrl.getTimer(); sendAbs(PingRequest.create(++_pingIndex)); }
private void Update() { if (_testPause) { if (Ctrl.getTimer() >= _resumeTime) { Ctrl.print("暂停恢复"); _testPause = false; } else { return; } } Ctrl.makeFixDirty(); long now = Ctrl.getTimer(); int dd = (int)(now - _lastTime); _lastTime = now; if (dd > 0) { if ((_dateFixDelayTick -= dd) <= 0) { _dateFixDelayTick = ShineSetting.dateFixDelay; DateControl.makeFixDirty(); } //系统逻辑 SystemControl.onFrame(); //计时器 TimeDriver.instance.tick(dd); } TimeDriver.instance.update(); //线程事务最后执行 if (dd > 0) { //线程 ThreadControl.onFrame(); } }
//心跳回复(主线程) public void onRePing(int index) { refreshPingTime(); _pingSending = false; //相同 if (_pingIndex == index) { _ping = (int)(Ctrl.getTimer() - _sendPingTime); // Ctrl.print("看ping",_ping); } else { _ping = -1; } sendAbs(AckPingRequest.create(index)); }
private void run() { try { SFuncQueue queue = _queue; _running = true; long lastTime = Ctrl.getTimer(); long time; int delay; int tickMax = _tickDelay; int tickTime = 0; while (_running) { time = Ctrl.getTimer(); delay = (int)(time - lastTime); lastTime = time; //防止系统时间改小 if (delay < 0) { delay = 0; } if (delay > 0) { if ((tickTime += delay) >= tickMax) { try { tick(tickTime); } catch (Exception e) { Ctrl.errorLog("线程tick出错", e); } tickTime = 0; } } try { runEx(); } catch (Exception e) { Ctrl.errorLog("线程runEx出错", e); } //再事务 queue.runOnce(); //最后睡 threadSleep(); } } catch (ThreadAbortException) { //线程结束 } catch (Exception e) { Ctrl.printExceptionForIO(e); } }
private void Start() { _lastTime = Ctrl.getTimer(); }