Allow passing a name to underlaying LLThread in debug mode.

This commit is contained in:
Aleric Inglewood
2013-01-29 20:44:14 +01:00
parent 1c8027b1e6
commit d5ed31ca9b
2 changed files with 20 additions and 4 deletions

View File

@@ -36,7 +36,13 @@ class AIStateMachineThreadBase::Thread : public LLThread {
LLPointer<AIThreadImpl> mImpl;
bool mNeedCleanup;
public:
Thread(AIThreadImpl* impl) : LLThread("AIStateMachineThreadBase::Thread"), mImpl(impl) { }
Thread(AIThreadImpl* impl) :
#ifdef LL_DEBUG
LLThread(impl->getName()),
#else
LLThread("AIStateMachineThreadBase::Thread"),
#endif
mImpl(impl) { }
protected:
/*virtual*/ void run(void)
{

View File

@@ -44,8 +44,8 @@ class HelloWorldThread : public AIThreadImpl {
public:
// Constructor.
HelloWorldThread(AIStateMachineThreadBase* state_machine_thread) :
AIThreadImpl(state_machine_thread), mStdErr(false), mSuccess(false) { } // MAIN THREAD
HelloWorldThread(AIStateMachineThreadBase* state_machine_thread) : // MAIN THREAD
AIThreadImpl(state_machine_thread, "HelloWorldThread"), mStdErr(false), mSuccess(false) { }
// Some initialization function (if needed).
void init(bool err) { mStdErr = err; } // MAIN THREAD
@@ -154,14 +154,24 @@ class AIThreadImpl : public LLThreadSafeRefCount {
private:
typedef AIAccess<AIStateMachineThreadBase*> StateMachineThread_wat;
AIThreadSafeSimpleDC<AIStateMachineThreadBase*> mStateMachineThread;
#ifdef LL_DEBUG
char const* mName;
#endif
protected:
AIThreadImpl(AIStateMachineThreadBase* state_machine_thread) : mStateMachineThread(state_machine_thread) { }
AIThreadImpl(AIStateMachineThreadBase* state_machine_thread, char const* name = "AIStateMachineThreadBase::Thread") : mStateMachineThread(state_machine_thread)
#ifdef LL_DEBUG
, mName(name)
#endif
{ }
public:
virtual bool run(void) = 0;
bool thread_done(bool result);
bool state_machine_done(LLThread* threadp);
#ifdef LL_DEBUG
char const* getName(void) const { return mName; }
#endif
};
// The base class for statemachine threads.