From c15f92320dd45846b5c4df448ce7e14a7912dbd3 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 22 Sep 2021 18:32:33 -0700 Subject: [PATCH] threadpool: don't run cancelled ticket --- app/threading/threadpool.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/threading/threadpool.cpp b/app/threading/threadpool.cpp index 38047a5ec..cef8500c0 100644 --- a/app/threading/threadpool.cpp +++ b/app/threading/threadpool.cpp @@ -83,15 +83,21 @@ void ThreadPool::RunNext() RenderTicketPtr ticket = ticket_queue_.front(); ticket_queue_.pop_front(); - ThreadPoolThread* thread = available_threads_.front(); - available_threads_.pop_front(); - - // Move ticket to other thread so event processing can occur there ticket->Start(); - ticket->moveToThread(thread); - // Run the ticket in the thread, which actually just calls our virtual function RunTicket - thread->RunTicket(ticket); + if (ticket->IsCancelled()) { + // Finish without doing any more + ticket->Finish(); + } else { + ThreadPoolThread* thread = available_threads_.front(); + available_threads_.pop_front(); + + // Move ticket to other thread so event processing can occur there + ticket->moveToThread(thread); + + // Run the ticket in the thread, which actually just calls our virtual function RunTicket + thread->RunTicket(ticket); + } } }