mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Added internal thread name support, for use with debuggers.
This commit is contained in:
@@ -37,6 +37,7 @@ Audio::PoolThread::PoolThread(Pool *pool)
|
||||
, finish(false)
|
||||
{
|
||||
mutex = thread::newMutex();
|
||||
threadName = "AudioPool";
|
||||
}
|
||||
|
||||
Audio::PoolThread::~PoolThread()
|
||||
|
||||
@@ -38,6 +38,7 @@ LuaThread::LuaThread(const std::string &name, love::Data *code)
|
||||
, nargs(0)
|
||||
{
|
||||
code->retain();
|
||||
threadName = name;
|
||||
}
|
||||
|
||||
LuaThread::~LuaThread()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user