Fixes for vmu profiler / thread

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis
2025-03-16 16:44:37 +02:00
parent ebf19d1e21
commit be52c1cf54
2 changed files with 11 additions and 4 deletions

View File

@@ -14,11 +14,17 @@ Thread::Thread(const char* label, size_t stackSize, bool detached, RunFunction r
}
Thread::~Thread() {
if(!detached_) join();
if(!detached_) {
join();
} else {
#if !defined(DC_SH4)
delete reinterpret_cast<std::thread*>(nativeHandle_);
#endif
}
}
bool Thread::spawn(const char *label, size_t stackSize, bool detached, RunFunction runFunction, void* param) {
#ifdef DC_SH4
#if defined(DC_SH4)
const kthread_attr_t thdAttr = {
.create_detached = detached,
.stack_size = stackSize,
@@ -40,10 +46,11 @@ bool Thread::join() {
if(!isValid() || detached_)
return false;
#ifdef DC_SH4
#if defined(DC_SH4)
if(thd_join(reinterpret_cast<kthread_t*>(nativeHandle_), nullptr) != 0)
return false;
#else
reinterpret_cast<std::thread*>(nativeHandle_)->join();
delete reinterpret_cast<std::thread*>(nativeHandle_);
#endif

View File

@@ -62,7 +62,7 @@ protected:
VmuProfiler();
// Main entry point and loop for the monitor thread
virtual void run();
void run();
public: