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

For #906, #902, use coroutine for reusable thread

This commit is contained in:
winlin 2017-05-29 20:33:32 +08:00
parent 2ed2513f08
commit ea9a5f26d9
18 changed files with 174 additions and 274 deletions

View file

@ -78,89 +78,6 @@ void SrsCoroutineManager::clear()
}
}
ISrsReusableThreadHandler::ISrsReusableThreadHandler()
{
}
ISrsReusableThreadHandler::~ISrsReusableThreadHandler()
{
}
void ISrsReusableThreadHandler::on_thread_start()
{
}
int ISrsReusableThreadHandler::on_before_cycle()
{
return ERROR_SUCCESS;
}
int ISrsReusableThreadHandler::on_end_cycle()
{
return ERROR_SUCCESS;
}
void ISrsReusableThreadHandler::on_thread_stop()
{
}
SrsReusableThread::SrsReusableThread(const char* n, ISrsReusableThreadHandler* h, int64_t cims)
{
handler = h;
pthread = new internal::SrsThread(n, this, cims, true);
}
SrsReusableThread::~SrsReusableThread()
{
pthread->stop();
srs_freep(pthread);
}
int SrsReusableThread::start()
{
return pthread->start();
}
void SrsReusableThread::stop()
{
pthread->stop();
}
bool SrsReusableThread::can_loop()
{
return pthread->can_loop();
}
int SrsReusableThread::cid()
{
return pthread->cid();
}
int SrsReusableThread::cycle()
{
return handler->cycle();
}
void SrsReusableThread::on_thread_start()
{
handler->on_thread_start();
}
int SrsReusableThread::on_before_cycle()
{
return handler->on_before_cycle();
}
int SrsReusableThread::on_end_cycle()
{
return handler->on_end_cycle();
}
void SrsReusableThread::on_thread_stop()
{
handler->on_thread_stop();
}
ISrsReusableThread2Handler::ISrsReusableThread2Handler()
{
}