Ai
4 Star 6 Fork 2

Gitee 极速下载/OpenBTS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/RangeNetworks/openbts
克隆/下载
L3Utils.cpp 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Iedema 提交于 2014-07-17 05:57 +08:00 . merge 5.0 preview from commercial
/*
* Copyright 2013, 2014 Range Networks, Inc.
*
* This software is distributed under multiple licenses;
* see the COPYING file in the main directory for licensing
* information for this specific distribution.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
// Written by Pat Thompson
#define LOG_GROUP LogGroup::Control // Can set Log.Level.Control for debugging
#include "L3Utils.h"
#include "L3StateMachine.h"
#define CASENAME(x) case x: return #x;
namespace Control {
const char *TimerId2Str(L3TimerId tid)
{
switch (tid) {
CASENAME(T301)
CASENAME(T302)
CASENAME(T303)
CASENAME(T304)
CASENAME(T305)
CASENAME(T308)
CASENAME(T310)
CASENAME(T313)
CASENAME(T3101)
CASENAME(T3113)
CASENAME(T3260)
CASENAME(T3270)
CASENAME(TR1M)
CASENAME(TR2M)
CASENAME(THandoverComplete)
CASENAME(TSipHandover)
CASENAME(TMisc1)
CASENAME(TCancel)
CASENAME(TMMCancel)
case cNumTimers: break;
// The last entry is not a timer - it is the number of max number of timers defined.
};
return "invalid";
}
const char * L3Timer::tName() const { return TimerId2Str(mTimerId); }
// Start a timer that will abort the procedure.
//void L3TimerList::timerStartAbortTran(L3TimerId tid, long wEndtime) {
//mtlTimers[tid].tStart(tid,wEndtime,L3Timer::AbortTran);
//}
void L3TimerList::timerStart(L3TimerId tid, unsigned wEndtime, int nextState) {
mtlTimers[tid].tStart(tid,wEndtime,nextState);
}
void L3TimerList::timerStop(L3TimerId tid) {
mtlTimers[tid].tStop();
}
void L3TimerList::timerStopAll() {
for (int tid = 0; tid < cNumTimers; tid++) {
mtlTimers[tid].tStop();
}
}
bool L3TimerList::timerExpired(L3TimerId tid) {
return mtlTimers[tid].tIsExpired();
}
// Trigger any expired timers. Return true if any have gone off.
bool L3TimerList::checkTimers() {
for (int tid = 0; tid < cNumTimers; tid++) {
if (mtlTimers[tid].tIsExpired()) {
mtlTimers[tid].tStop();
lockAndInvokeTimeout(&mtlTimers[tid]);
// Since the timer can result in the transaction being killed, only trigger one timer
// then we return to let the caller invoke us again if the transaction is still active.
return true;
}
}
return false;
}
void L3TimerList::text(std::ostream &os) const {
for (int tid = 0; tid < cNumTimers; tid++) {
const L3Timer *timer = &mtlTimers[tid];
if (timer->tIsExpired()) { os <<LOGVAR2(timer->tName(),"expired"); }
if (timer->tRemaining()) { os <<LOGVAR2(timer->tName(),timer->tRemaining()); }
}
}
// Return the remaining time of any timers, or nextTimeout if none active.
// The idiom is to pass it -1, and it returns it if no timers running.
// This was meant for the single-thread version of the State Machines and is not currently used.
int L3TimerList::remainingTime() {
int nextTimeout = -1;
for (L3TimerId tid = (L3TimerId)0; tid < cNumTimers; tid = (L3TimerId)(tid + 1)) {
if (mtlTimers[tid].tIsActive()) {
int remaining = mtlTimers[tid].tRemaining();
if (nextTimeout == -1) {
nextTimeout = remaining;
} else {
nextTimeout = min(nextTimeout,remaining);
}
}
}
return nextTimeout;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/openbts.git
git@gitee.com:mirrors/openbts.git
mirrors
openbts
OpenBTS
master

搜索帮助