Added cCondWait::Sleep() and using it to replace all usleep() calls

This commit is contained in:
Klaus Schmidinger
2004-10-24 11:12:05 +02:00
parent 70e6038056
commit 9f51fcad22
7 changed files with 25 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: thread.c 1.34 2004/10/24 10:27:47 kls Exp $
* $Id: thread.c 1.35 2004/10/24 11:05:56 kls Exp $
*/
#include "thread.h"
@@ -32,6 +32,12 @@ cCondWait::~cCondWait()
pthread_mutex_destroy(&mutex);
}
void cCondWait::SleepMs(int TimeoutMs)
{
cCondWait w;
w.Wait(TimeoutMs);
}
bool cCondWait::Wait(int TimeoutMs)
{
pthread_mutex_lock(&mutex);
@@ -265,7 +271,7 @@ void cThread::Cancel(int WaitSeconds)
for (time_t t0 = time(NULL) + WaitSeconds; time(NULL) < t0; ) {
if (!Active())
return;
usleep(10000);
cCondWait::SleepMs(10);
}
esyslog("ERROR: thread %ld won't end (waited %d seconds) - cancelling it...", childTid, WaitSeconds);
}
@@ -433,7 +439,7 @@ int cPipe::Close(void)
else if (ret == pid)
break;
i--;
usleep(100000);
cCondWait::SleepMs(100);
}
if (!i) {
kill(pid, SIGKILL);