task: Add the ability to name threads
This commit is contained in:
parent
e70e065ffe
commit
5428763559
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue