diff --git a/desmume/src/utils/task.cpp b/desmume/src/utils/task.cpp index e696c8d51..0e591863a 100644 --- a/desmume/src/utils/task.cpp +++ b/desmume/src/utils/task.cpp @@ -30,7 +30,7 @@ public: Impl(); ~Impl(); - void start(bool spinlock, int threadPriority); + void start(bool spinlock, int threadPriority, const char *name); void execute(const TWork &work, void *param); void* finish(); void shutdown(); @@ -87,7 +87,7 @@ Task::Impl::~Impl() scond_free(condWork); } -void Task::Impl::start(bool spinlock, int threadPriority) +void Task::Impl::start(bool spinlock, int threadPriority, const char *name) { slock_lock(this->mutex); @@ -102,6 +102,8 @@ void Task::Impl::start(bool spinlock, int threadPriority) this->exitThread = false; this->_thread = sthread_create_with_priority(&taskProc, this, threadPriority); this->_isThreadRunning = true; + if (name) + sthread_setname(this->_thread, name); slock_unlock(this->mutex); } @@ -168,8 +170,8 @@ void Task::Impl::shutdown() slock_unlock(this->mutex); } -void Task::start(bool spinlock) { impl->start(spinlock, 0); } -void Task::start(bool spinlock, int threadPriority) { impl->start(spinlock, threadPriority); } +void Task::start(bool spinlock) { impl->start(spinlock, 0, nullptr); } +void Task::start(bool spinlock, int threadPriority, const char *name) { impl->start(spinlock, threadPriority, name); } void Task::shutdown() { impl->shutdown(); } Task::Task() : impl(new Task::Impl()) {} Task::~Task() { delete impl; } diff --git a/desmume/src/utils/task.h b/desmume/src/utils/task.h index eab44fd1d..e4053d741 100644 --- a/desmume/src/utils/task.h +++ b/desmume/src/utils/task.h @@ -30,7 +30,7 @@ public: // initialize task runner void start(bool spinlock); - void start(bool spinlock, int threadPriority); + void start(bool spinlock, int threadPriority, const char *name = nullptr); //execute some work void execute(const TWork &work, void* param);