sip线程
来源:互联网 发布:程序员电脑壁纸 编辑:程序博客网 时间:2024/06/05 16:56
这是注册主函数中的循环:
while ( !clientHandler.done )
{
FdSet fdset;
stack->buildFdSet(fdset);
int err = fdset.selectMilliSeconds(100);
assert ( err != -1 );
stack->process(fdset);
while(dum->process());
if (n == 1000) clientHandler.done = true;
if (!(n++ % 10)) cerr << "|/-//"[(n/10)%4] << '/b';
}
显然,它的作用是循环调用两个函数:
stack->process(fdset);
dum->process();
那么它跟直接用StarcThread::thread() DumThread::thread()直接启动一个线程有什么关系呢?
我们看下调用:run()---àStarcThread::thread()发生了什么:
void
StackThread::thread()
{
while (!isShutdown())
{
try
{
resip::FdSet fdset;
buildFdSet(fdset);
mStack.buildFdSet(fdset);
int ret = fdset.selectMilliSeconds(resipMin(mStack.getTimeTillNextProcessMS(),
getTimeTillNextProcessMS()));
if (ret >= 0)
{
// .dlb. use return value to peak at the message to see if it is a
// shutdown, and call shutdown if it is
beforeProcess();
mStack.process(fdset);
afterProcess();
}
}
catch (BaseException& e)
{
ErrLog (<< "Unhandled exception: " << e);
}
}
}
void DumThread::thread()
{
while (!isShutdown())
{
try
{
std::auto_ptr<Message> msg(mDum.mFifo.getNext(1000));
if (msg.get())
{
mDum.internalProcess(msg);
}
}
catch (BaseException& e)
{
}
}
}
结论:循环掉用stack->process(fdset)和dum->process()与直接stack.run()和dum.run()是一样的。
Run à thread à process
- sip线程
- sip
- SIP
- SIP
- SIP
- SIP
- SIP
- SIP
- SIP
- SIP
- SIP
- sip
- sip
- SIP
- SIP
- sip
- SIP
- SIP
- Transit-ETREE/HVPLS
- [转]java的优化建议
- servlet的实例变量是线程不安全的,而其JSP也默认是以多线程方式执行
- 字符串反转
- MyEclipse连接打开数据库(以mysql为例)
- sip线程
- OS-Ucos/Rtems/Vxworks/Linux基本函数接口对比
- 确定指定数据范围内数据个数C语言
- 大数处理之:能被六整除的数串
- Linq删除
- 用户体验的76个体验点
- iphone开发之获取是否飞行模式和设备IMEI
- Ewebeditor 2.1.6上传漏洞 UNION运用-直接得SHELL
- 包含子目录的makefile例子