issue#I5KOL1 Use pthread_cond_timedwait instead of pthread_cond_wait to handle

m_readySessionList when all workers are idle
This commit is contained in:
Chunling Wang
2022-07-28 18:28:43 +08:00
parent a4bdb7450b
commit 573423cac6
4 changed files with 21 additions and 4 deletions

View File

@ -75,13 +75,17 @@ int ThreadPoolStream::StartUp(int idx, StreamProducer* producer, ThreadPoolGroup
void ThreadPoolStream::WaitMission()
{
struct timespec ts;
PreventSignal();
pthread_mutex_lock(m_mutex);
while (m_producer == NULL) {
if (m_threadStatus == THREAD_EXIT) {
break;
}
pthread_cond_wait(m_cond, m_mutex);
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 10; // 10s
ts.tv_nsec = 0;
pthread_cond_timedwait(m_cond, m_mutex, &ts);
}
pthread_mutex_unlock(m_mutex);
Assert(t_thrd.proc->pid == t_thrd.proc_cxt.MyProcPid);