1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine the thread to three category.

This commit is contained in:
winlin 2015-05-23 09:20:16 +08:00
parent 2f0ef87d6d
commit e5f449ce36
25 changed files with 648 additions and 416 deletions

View file

@ -50,7 +50,7 @@ SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtm
timeout = timeout_ms;
handler = msg_handler;
rtmp = rtmp_sdk;
trd = new SrsThread("recv", this, 0, true);
trd = new SrsReusableThread("recv", this);
}
SrsRecvThread::~SrsRecvThread()
@ -76,7 +76,7 @@ int SrsRecvThread::cycle()
{
int ret = ERROR_SUCCESS;
while (trd->can_loop()) {
while (!trd->interrupted()) {
if (!handler->can_handle()) {
st_usleep(timeout * 1000);
continue;
@ -96,7 +96,7 @@ int SrsRecvThread::cycle()
}
// we use no timeout to recv, should never got any error.
trd->stop_loop();
trd->interrupt();
// notice the handler got a recv error.
handler->on_recv_error(ret);
@ -111,7 +111,7 @@ int SrsRecvThread::cycle()
void SrsRecvThread::stop_loop()
{
trd->stop_loop();
trd->interrupt();
}
void SrsRecvThread::on_thread_start()