mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Added cCondWait::Sleep() and using it to replace all usleep() calls
This commit is contained in:
12
thread.c
12
thread.c
@@ -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);
|
||||
|
Reference in New Issue
Block a user