Added internal thread name support, for use with debuggers.

This commit is contained in:
Alex Szpakowski
2014-05-02 08:56:23 -03:00
parent e4dc533bb2
commit 1bc8b7346d
5 changed files with 16 additions and 1 deletions
+1
View File
@@ -37,6 +37,7 @@ Audio::PoolThread::PoolThread(Pool *pool)
, finish(false)
{
mutex = thread::newMutex();
threadName = "AudioPool";
}
Audio::PoolThread::~PoolThread()
+1
View File
@@ -38,6 +38,7 @@ LuaThread::LuaThread(const std::string &name, love::Data *code)
, nargs(0)
{
code->retain();
threadName = name;
}
LuaThread::~LuaThread()
+1 -1
View File
@@ -51,7 +51,7 @@ bool Thread::start()
return false;
if (thread) // Clean old handle up
SDL_WaitThread(thread, 0);
thread = SDL_CreateThread(thread_runner, NULL, this);
thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
running = (thread != 0);
return running;
}
+5
View File
@@ -99,5 +99,10 @@ bool Threadable::isRunning() const
return owner->isRunning();
}
const char *Threadable::getThreadName() const
{
return threadName.empty() ? nullptr : threadName.c_str();
}
} // thread
} // love
+8
View File
@@ -21,9 +21,13 @@
#ifndef LOVE_THREAD_THREADS_H
#define LOVE_THREAD_THREADS_H
// LOVE
#include "common/config.h"
#include "Thread.h"
// C++
#include <string>
namespace love
{
namespace thread
@@ -83,9 +87,13 @@ public:
bool start();
void wait();
bool isRunning() const;
const char *getThreadName() const;
protected:
Thread *owner;
std::string threadName;
};
Mutex *newMutex();