1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Removed the recursion stuff from cThread (cMutex already does this)

This commit is contained in:
Klaus Schmidinger 2001-10-27 13:23:06 +02:00
parent fd4d1f77f2
commit 17cdf085c7
3 changed files with 11 additions and 35 deletions

View File

@ -843,3 +843,4 @@ Video Disk Recorder Revision History
- Updated 'channels.conf' for the "Bundesliga" channels of Premiere World - Updated 'channels.conf' for the "Bundesliga" channels of Premiere World
(thanks to Helmut Schächner). (thanks to Helmut Schächner).
- Changed the tuning code to use FrontendInfo to detect the type of DVB card. - Changed the tuning code to use FrontendInfo to detect the type of DVB card.
- Removed the recursion stuff from cThread (cMutex already does this).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: thread.c 1.15 2001/10/21 12:25:31 kls Exp $ * $Id: thread.c 1.16 2001/10/27 13:23:06 kls Exp $
*/ */
#include "thread.h" #include "thread.h"
@ -99,8 +99,7 @@ cThread::cThread(void)
signalHandlerInstalled = true; signalHandlerInstalled = true;
} }
running = false; running = false;
parentPid = threadPid = lockingPid = 0; parentPid = threadPid = 0;
locked = 0;
} }
cThread::~cThread() cThread::~cThread()
@ -159,24 +158,6 @@ void cThread::Cancel(int WaitSeconds)
pthread_cancel(thread); pthread_cancel(thread);
} }
bool cThread::Lock(void)
{
if (getpid() != lockingPid || !locked) {
Mutex.Lock();
lockingPid = getpid();
}
locked++;
return true;
}
void cThread::Unlock(void)
{
if (!--locked) {
lockingPid = 0;
Mutex.Unlock();
}
}
void cThread::WakeUp(void) void cThread::WakeUp(void)
{ {
kill(parentPid, SIGIO); // makes any waiting 'select()' call return immediately kill(parentPid, SIGIO); // makes any waiting 'select()' call return immediately
@ -228,17 +209,13 @@ bool cThreadLock::Lock(cThread *Thread)
{ {
if (Thread && !thread) { if (Thread && !thread) {
thread = Thread; thread = Thread;
locked = Thread->Lock(); Thread->Lock();
return locked; locked = true;
return true;
} }
return false; return false;
} }
bool cThreadLock::Locked(void)
{
return locked;
}
// --- cPipe ----------------------------------------------------------------- // --- cPipe -----------------------------------------------------------------
// cPipe::Open() and cPipe::Close() are based on code originally received from // cPipe::Open() and cPipe::Close() are based on code originally received from

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: thread.h 1.10 2001/10/20 10:25:19 kls Exp $ * $Id: thread.h 1.11 2001/10/27 13:22:20 kls Exp $
*/ */
#ifndef __THREAD_H #ifndef __THREAD_H
@ -45,9 +45,8 @@ class cThread {
friend class cThreadLock; friend class cThreadLock;
private: private:
pthread_t thread; pthread_t thread;
cMutex Mutex; cMutex mutex;
pid_t parentPid, threadPid, lockingPid; pid_t parentPid, threadPid;
int locked;
bool running; bool running;
static time_t lastPanic; static time_t lastPanic;
static int panicLevel; static int panicLevel;
@ -55,8 +54,8 @@ private:
static bool signalHandlerInstalled; static bool signalHandlerInstalled;
static void SignalHandler(int signum); static void SignalHandler(int signum);
static void *StartThread(cThread *Thread); static void *StartThread(cThread *Thread);
bool Lock(void); void Lock(void) { mutex.Lock(); }
void Unlock(void); void Unlock(void) { mutex.Unlock(); }
protected: protected:
void WakeUp(void); void WakeUp(void);
virtual void Action(void) = 0; virtual void Action(void) = 0;
@ -84,7 +83,6 @@ public:
cThreadLock(cThread *Thread = NULL); cThreadLock(cThread *Thread = NULL);
~cThreadLock(); ~cThreadLock();
bool Lock(cThread *Thread); bool Lock(cThread *Thread);
bool Locked(void);
}; };
#define LOCK_THREAD cThreadLock ThreadLock(this) #define LOCK_THREAD cThreadLock ThreadLock(this)