OpenRTMFP/Cumulus Primer(7)CumulusServer 启动流程分析(续3)
OpenRTMFP/Cumulus Primer(7)CumulusServer 启动流程分析(续3)- 作者:柳大Poechant(钟超)
- 博客:Blog.CSDN.net/Poechant
- 邮箱:zhongchao.ustc#gmail.com (# -> @)
- 日期:April 14th, 2012
1 回顾一下启动过程- 从 main.cpp 的启动入口
main()函数开始,创建Server对象并启动(调用start()函数)。 Server::start()中调用其父类(RTMFPServer)的父类(Startable)的方法Startable::start()开启线程。- 调用
Startable::start()函数后,开启线城时传入的参数为*this,所以就会运行Startable::run();
2 RTMFPServer::prerun()
Startable::run()调用Startable::prerun()函数,但这个函数被RTMFPServer覆盖,所以会运行?RTMFPServer::prerun(),其源码如下:
bool RTMFPServer::prerun() { NOTE("RTMFP server starts on %u port",_port);
如果CumulusEdge:
if (_edgesPort>0) NOTE("RTMFP edges server starts on %u port",_edgesPort); bool result = true; try { onStart();
运行线程:
result = Startable::prerun();
处理异常:
} catch(Exception& ex) { FATAL("RTMFPServer : %s",ex.displayText().c_str()); } catch (exception& ex) { FATAL("RTMFPServer : %s",ex.what()); } catch (...) { FATAL("RTMFPServer unknown error"); }
如果跳出了,则终止运行:
onStop(); NOTE("RTMFP server stops"); return result;}
该函数内部又会调用父类的 Startable::prerun() 函数,该函数调用:
virtual void Startable::run(const volatile bool& terminate) = 0;
它是一个纯虚函数,由 RTMFPServer 实现。
3 Startable::prerun()
Startable::prerun()会调用void run(const volatile bool& terminate)方法,该方法被RTMFPServer覆盖了。
bool Startable::prerun() { run(_terminate); return !_terminate;}
4 RTMFPServer::run(const volatile bool& terminate)
RTMFPServer覆盖Startable的run(const volatile bool &terminate)方法。
void RTMFPServer::run(const volatile bool& terminate) { ...}
-
转载请注明来自柳大的CSDN博客:Blog.CSDN.net/Poechant
-
1 回顾一下启动过程- 从 main.cpp 的启动入口
main()函数开始,创建Server对象并启动(调用start()函数)。 Server::start()中调用其父类(RTMFPServer)的父类(Startable)的方法Startable::start()开启线程。- 调用
Startable::start()函数后,开启线城时传入的参数为*this,所以就会运行Startable::run();
2 RTMFPServer::prerun()
main()函数开始,创建Server对象并启动(调用start()函数)。Server::start()中调用其父类(RTMFPServer)的父类(Startable)的方法Startable::start()开启线程。Startable::start()函数后,开启线城时传入的参数为*this,所以就会运行Startable::run();Startable::run()调用Startable::prerun()函数,但这个函数被RTMFPServer覆盖,所以会运行?RTMFPServer::prerun(),其源码如下:
bool RTMFPServer::prerun() { NOTE("RTMFP server starts on %u port",_port);如果CumulusEdge:
if (_edgesPort>0) NOTE("RTMFP edges server starts on %u port",_edgesPort); bool result = true; try { onStart();运行线程:
result = Startable::prerun();处理异常:
} catch(Exception& ex) { FATAL("RTMFPServer : %s",ex.displayText().c_str()); } catch (exception& ex) { FATAL("RTMFPServer : %s",ex.what()); } catch (...) { FATAL("RTMFPServer unknown error"); }如果跳出了,则终止运行:
onStop(); NOTE("RTMFP server stops"); return result;}该函数内部又会调用父类的 Startable::prerun() 函数,该函数调用:
virtual void Startable::run(const volatile bool& terminate) = 0;它是一个纯虚函数,由 RTMFPServer 实现。
3 Startable::prerun()
Startable::prerun()会调用void run(const volatile bool& terminate)方法,该方法被RTMFPServer覆盖了。
bool Startable::prerun() { run(_terminate); return !_terminate;}4 RTMFPServer::run(const volatile bool& terminate)
RTMFPServer覆盖Startable的run(const volatile bool &terminate)方法。
void RTMFPServer::run(const volatile bool& terminate) { ...}-
转载请注明来自柳大的CSDN博客:Blog.CSDN.net/Poechant
-