some debugging code.

This commit is contained in:
crs 2001-10-14 19:16:54 +00:00
parent b3291bc2b5
commit 9435639545
3 changed files with 18 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "XThread.h"
#include "CLock.h"
#include "CStopwatch.h"
#include "CLog.h"
//
// CThreadPtr
@ -75,6 +76,8 @@ void CThread::sleep(double timeout)
void CThread::exit(void* result)
{
CThreadPtr currentRep(CThreadRep::getCurrentThreadRep());
log((CLOG_DEBUG "throw exit on thread %p", currentRep.operator->()));
throw XThreadExit(result);
}

View File

@ -3,6 +3,7 @@
#include "CMutex.h"
#include "CLock.h"
#include "XThread.h"
#include "CLog.h"
#include "IJob.h"
#include <assert.h>
@ -229,14 +230,19 @@ void CThreadRep::doThreadFunc()
catch (XThreadCancel&) {
// client called cancel()
log((CLOG_DEBUG "caught cancel on thread %p", this));
}
catch (XThreadExit& e) {
// client called exit()
result = e.m_result;
log((CLOG_DEBUG "caught exit on thread %p", this));
}
catch (...) {
log((CLOG_DEBUG "caught exit on thread %p", this));
// note -- don't catch (...) to avoid masking bugs
throw;
}
// done with job
delete m_job;
@ -286,6 +292,7 @@ void CThreadRep::cancel()
m_cancel = true;
// break out of system calls
log((CLOG_DEBUG "cancel thread %p", this));
pthread_kill(m_thread, SIGALRM);
}
}
@ -304,6 +311,7 @@ void CThreadRep::testCancel()
}
// start cancel
log((CLOG_DEBUG "throw cancel on thread %p", this));
throw XThreadCancel();
}
@ -401,6 +409,7 @@ void CThreadRep::sleep(double timeout)
void CThreadRep::cancel()
{
log((CLOG_DEBUG "cancel thread %p", this));
SetEvent(m_cancel);
}
@ -423,6 +432,7 @@ void CThreadRep::testCancel()
}
// start cancel
log((CLOG_DEBUG "throw cancel on thread %p", this));
throw XThreadCancel();
}

View File

@ -18,7 +18,10 @@ CTimerThread::CTimerThread(double timeout) : m_timeout(timeout)
CTimerThread::~CTimerThread()
{
log((CLOG_DEBUG "cancelling timeout"));
m_timingThread->cancel();
m_timingThread->wait();
log((CLOG_DEBUG "cancelled timeout"));
delete m_timingThread;
delete m_callingThread;
}