Пример #1
0
///时钟函数
void CwxMqApp::onTime(CwxTimeValue const& current) {
  ///调用基类的onTime函数
  CwxAppFramework::onTime(current);
  m_ttCurTime = current.sec();
  ///检查超时
  static CWX_UINT32 ttTimeBase = 0; ///<时钟回跳的base时钟
  static CWX_UINT32 ttLastTime = m_ttCurTime; ///<上一次检查的时间
  bool bClockBack = isClockBack(ttTimeBase, m_ttCurTime);
  if (bClockBack || (m_ttCurTime >= ttLastTime + 1)) {
    ttLastTime = m_ttCurTime;
    if (m_config.getCommon().m_bMaster) {
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_TYPE_RECV);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      //将超时检查事件,放入事件队列
      m_recvThreadPool->append(pBlock);
    } else {
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_TYPE_MASTER);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      //将超时检查事件,放入事件队列
      m_recvThreadPool->append(pBlock);
    }
    //若存在分发线程池,则往分发线程池append TIMEOUT_CHECK
    if (m_dispThreadPool) {
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_TYPE_DISP);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      //将超时检查事件,放入事件队列
      m_dispThreadPool->append(pBlock);
    }
    //若存在mq程池,则往mq线程池append TIMEOUT_CHECK
    if (m_mqThreadPool) {
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_TYPE_QUEUE);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      //将超时检查事件,放入事件队列
      m_mqThreadPool->append(pBlock);
    }
  }
}
Пример #2
0
///时钟函数
void CwxProProxyApp::onTime(CwxTimeValue const& current) {
  ///调用基类的onTime函数
  CwxAppFramework::onTime(current);
  m_ttCurTime = current.sec();
  ///检查超时
  static CWX_UINT32 ttTimeBase = 0; ///<时钟回跳的base时钟
  static CWX_UINT32 ttLastTime = 0; ///<上次检查时间
  bool bClockBack = isClockBack(ttTimeBase, m_ttCurTime);
  if (bClockBack || (m_ttCurTime >= ttLastTime + 1)) {
    ttLastTime = m_ttCurTime;
    if (m_zkThreadPool) { ///发送超时检查到zk线程
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_PRO_TYPE_ZK);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      m_zkThreadPool->append(pBlock);
    }
    if (m_mqThreadPool) { ///发送超时检查到mq线程
      CwxMsgBlock* pBlock = CwxMsgBlockAlloc::malloc(0);
      pBlock->event().setSvrId(SVR_PRO_TYPE_RECV);
      pBlock->event().setEvent(CwxEventInfo::TIMEOUT_CHECK);
      m_mqThreadPool->append(pBlock);
    }
  }
}