Browse Source

Added internal thread name support, for use with debuggers.

Alex Szpakowski 11 years ago
parent
commit
1bc8b7346d

+ 1 - 0
src/modules/audio/openal/Audio.cpp

@@ -37,6 +37,7 @@ Audio::PoolThread::PoolThread(Pool *pool)
 	, finish(false)
 {
 	mutex = thread::newMutex();
+	threadName = "AudioPool";
 }
 
 Audio::PoolThread::~PoolThread()

+ 1 - 0
src/modules/thread/LuaThread.cpp

@@ -38,6 +38,7 @@ LuaThread::LuaThread(const std::string &name, love::Data *code)
 	, nargs(0)
 {
 	code->retain();
+	threadName = name;
 }
 
 LuaThread::~LuaThread()

+ 1 - 1
src/modules/thread/sdl/Thread.cpp

@@ -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 - 0
src/modules/thread/threads.cpp

@@ -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 - 0
src/modules/thread/threads.h

@@ -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();