summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2003-10-18 12:29:08 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2003-10-18 12:29:08 +0200
commite53e43d2b85095ec24e89fb8721d9c92e13ed930 (patch)
treeed5b2d1614a146e986ad2fee4b8933b52cb160b5 /thread.c
parent15816ee8e4a1be96bba1da9199739f1666a87703 (diff)
downloadvdr-e53e43d2b85095ec24e89fb8721d9c92e13ed930.tar.gz
vdr-e53e43d2b85095ec24e89fb8721d9c92e13ed930.tar.bz2
The cThread class now accepts a 'Description' parameter
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index f30e7cc1..49c01a24 100644
--- a/thread.c
+++ b/thread.c
@@ -4,12 +4,14 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.c 1.26 2003/10/18 10:29:25 kls Exp $
+ * $Id: thread.c 1.27 2003/10/18 12:14:55 kls Exp $
*/
#include "thread.h"
#include <errno.h>
+#include <malloc.h>
#include <signal.h>
+#include <stdarg.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -118,7 +120,7 @@ void cMutex::Unlock(void)
bool cThread::signalHandlerInstalled = false;
bool cThread::emergencyExitRequested = false;
-cThread::cThread(void)
+cThread::cThread(const char *Description)
{
if (!signalHandlerInstalled) {
signal(SIGIO, SignalHandler);
@@ -126,10 +128,25 @@ cThread::cThread(void)
}
running = false;
parentTid = childTid = 0;
+ description = NULL;
+ SetDescription(Description);
}
cThread::~cThread()
{
+ free(description);
+}
+
+void cThread::SetDescription(const char *Description, ...)
+{
+ free(description);
+ description = NULL;
+ if (Description) {
+ va_list ap;
+ va_start(ap, Description);
+ vasprintf(&description, Description, ap);
+ va_end(ap);
+ }
}
void cThread::SignalHandler(int signum)
@@ -140,7 +157,11 @@ void cThread::SignalHandler(int signum)
void *cThread::StartThread(cThread *Thread)
{
Thread->childTid = pthread_self();
+ if (Thread->description)
+ dsyslog("%s thread started (pid=%d, tid=%ld)", Thread->description, getpid(), Thread->childTid);
Thread->Action();
+ if (Thread->description)
+ dsyslog("%s thread ended (pid=%d, tid=%ld)", Thread->description, getpid(), Thread->childTid);
Thread->childTid = 0;
return NULL;
}