derive threadpool from cancelableobject

This commit is contained in:
itsmattkc
2020-10-30 22:48:25 +11:00
parent 26e351d363
commit 60eb71cb4c
3 changed files with 18 additions and 13 deletions
+6 -8
View File
@@ -96,7 +96,6 @@ void ThreadPool::ThreadDone()
ThreadPoolThread::ThreadPoolThread(ThreadPool *parent)
{
pool_ = parent;
cancelled_ = false;
// Ensures mutex is definitely locked by the time the thread is running
mutex_.lock();
@@ -115,15 +114,9 @@ void ThreadPoolThread::RunTicket(RenderTicketPtr ticket)
mutex_.unlock();
}
void ThreadPoolThread::Cancel()
{
cancelled_ = true;
wait_cond_.wakeAll();
}
void ThreadPoolThread::run()
{
while (!cancelled_) {
while (!IsCancelled()) {
wait_cond_.wait(&mutex_);
if (ticket_) {
@@ -135,4 +128,9 @@ void ThreadPoolThread::run()
}
}
void ThreadPoolThread::CancelEvent()
{
wait_cond_.wakeAll();
}
OLIVE_NAMESPACE_EXIT