Openrtmfp/Cumulus primer (23) thread Logic Analysis II: rtmfpmanager's impact on rtmfpserver

Source: Internet
Author: User
Tags thread logic
Openrtmfp/Cumulus primer (23) thread Logic Analysis II: rtmfpmanager's impact on rtmfpserver
  • Author: Liu Da poechant (Zhong Chao Michael)
  • Blog: blog.csdn.net/poechant
  • Email: zhongchao.ustc@gmail.com
  • Date: August 5Th, 2012

RTMFPManagerAndRTMFPServerSimilarly, it inherits fromStartable.

class RTMFPManager : private Task, private Startable

In the constructorRTMFPServerObject is passed in as a reference to initialize its_serverReference a member.

RTMFPManager(RTMFPServer& server)    : _server(server),      Task(server),      Startable("RTMFPManager")  {    start();}. . .RTMFPServer& _server;

InRTMFPManagerIs called in the constructorstart()The member function is fromStartableInherited. Then, a new name namedRTMFPManager. Then respondRTMFPManager::run()Function.

void run() {    setPriority(Thread::PRIO_LOW);    while(sleep(2000)!=STOP)        waitHandle();}

It should be emphasized thatsetPriorityInLinuxThe setting fails in the environment. For more information, seeCumulusInGithubEnabled onIssue #75Including the thread priority settings.

Here we can seeRTMFPManagerOfhandle(…)Insleep(…)Is once every 2 seconds, and this isRTMFPServerThe thread has an impact. Remember what I saidRTMFPServerThread_wakeUpEventMember? (In openrtmfp/Cumulus primer (22) rtmfpserver thread start and wait)RTMFPManagerSo here this 2 seconds will affectRTMFPServerOf the main cycle.

Startable::WakeUpType Startable::sleep(UInt32 timeout) {    if(_stop)        return STOP;     WakeUpType result = WAKEUP;     if(timeout>0) {         if(!_wakeUpEvent.tryWait(timeout))             result = TIMEOUT;     } else {         _wakeUpEvent.wait();     }    if(_stop)        return STOP;    return result;}

You can modifyRTMFPServerMediumsleep(...)In this way,_wakeUpEvent.tryWait(timeout)According to the specified wait time (that istimeout) To sleep.

RTMFPManagerWhat is the role? Its core lies in itshandleMember functions:

void handle() {    _server.manage();}

This will be calledRTMFPServer::manage()So you need to readRTMFPServerSource codeRTMFPServer::manage()The function is notRTMFPServerRunning in the thread,RTMFPManagerRun in the thread. It is defined as follows:

void RTMFPServer::manage() {    _handshake.manage();    _sessions.manage();}

It manages existing sessions, such as terminating dead sessions.

-

For more information, see the csdn blog blog.csdn.net/poechant from LIU Da poechant (zhongchao ).

-

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.