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
RTMFPManager
AndRTMFPServer
Similarly, it inherits fromStartable
.
class RTMFPManager : private Task, private Startable
In the constructorRTMFPServer
Object is passed in as a reference to initialize its_server
Reference a member.
RTMFPManager(RTMFPServer& server) : _server(server), Task(server), Startable("RTMFPManager") { start();}. . .RTMFPServer& _server;
InRTMFPManager
Is called in the constructorstart()
The member function is fromStartable
Inherited. Then, a new name namedRTMFPManager
. Then respondRTMFPManager::run()
Function.
void run() { setPriority(Thread::PRIO_LOW); while(sleep(2000)!=STOP) waitHandle();}
It should be emphasized thatsetPriority
InLinux
The setting fails in the environment. For more information, seeCumulus
InGithub
Enabled onIssue #75
Including the thread priority settings.
Here we can seeRTMFPManager
Ofhandle(…)
Insleep(…)
Is once every 2 seconds, and this isRTMFPServer
The thread has an impact. Remember what I saidRTMFPServer
Thread_wakeUpEvent
Member? (In openrtmfp/Cumulus primer (22) rtmfpserver thread start and wait)RTMFPManager
So here this 2 seconds will affectRTMFPServer
Of 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 modifyRTMFPServer
Mediumsleep(...)
In this way,_wakeUpEvent.tryWait(timeout)
According to the specified wait time (that istimeout
) To sleep.
RTMFPManager
What is the role? Its core lies in itshandle
Member functions:
void handle() { _server.manage();}
This will be calledRTMFPServer::manage()
So you need to readRTMFPServer
Source codeRTMFPServer::manage()
The function is notRTMFPServer
Running in the thread,RTMFPManager
Run 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 ).
-