Do not hardcode the threadname in the CThread class

This commit is contained in:
Maschell 2022-10-05 19:59:04 +02:00
parent 85cedda15e
commit 45ea7ac07e
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#include "BackgroundThreadWrapper.hpp"
#include <coreinit/cache.h>
BackgroundThreadWrapper::BackgroundThreadWrapper(int32_t priority) : CThread(CThread::eAttributeAffCore2, priority, 0x100000) {
BackgroundThreadWrapper::BackgroundThreadWrapper(int32_t priority) : CThread(CThread::eAttributeAffCore2, priority, 0x100000, nullptr, nullptr, "FTPiiU Server") {
}
BackgroundThreadWrapper::~BackgroundThreadWrapper() {

View File

@ -21,6 +21,7 @@
#include <coreinit/systeminfo.h>
#include <coreinit/thread.h>
#include <malloc.h>
#include <string>
#include <unistd.h>
class CThread {
@ -28,7 +29,7 @@ public:
typedef void (*Callback)(CThread *thread, void *arg);
//! constructor
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr, const std::string &threadName = "")
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
//! save attribute assignment
iAttributes = iAttr;
@ -39,7 +40,8 @@ public:
//! create the thread
if (pThread && pThreadStack) {
OSCreateThread(pThread, &CThread::threadCallback, 1, (char *) this, pThreadStack + iStackSize, iStackSize, iPriority, iAttributes);
OSSetThreadName(pThread, "FTP Server Thread");
pThreadName = threadName;
OSSetThreadName(pThread, pThreadName.c_str());
}
}
@ -138,6 +140,7 @@ private:
uint8_t *pThreadStack;
Callback pCallback;
void *pCallbackArg;
std::string pThreadName;
};
#endif