Initial threadpool rewrite/cleanup

This commit is contained in:
Bennett
2022-05-04 09:39:43 -07:00
committed by Bennett Anderson
parent 5f13a83009
commit 11ea7fcb71
3 changed files with 91 additions and 203 deletions
+12 -26
View File
@@ -40,8 +40,7 @@ RenderManager* RenderManager::instance_ = nullptr;
const int RenderManager::kDecoderMaximumInactivity = 10000;
RenderManager::RenderManager(QObject *parent) :
ThreadPool(QThread::IdlePriority, 0, parent),
backend_(kOpenGL)
ThreadPool(0, parent), backend_(kOpenGL)
{
Renderer* graphics_renderer = nullptr;
@@ -160,14 +159,7 @@ RenderTicketPtr RenderManager::RenderFrame(ViewerOutput *viewer, ColorManager* c
ticket->setProperty("cache", cache->GetCacheDirectory());
}
if (ticket->thread() != this->thread()) {
ticket->moveToThread(this->thread());
}
// Queue appending the ticket and running the next job on our thread to make this function thread-safe
QMetaObject::invokeMethod(this, "AddTicket", Qt::AutoConnection,
OLIVE_NS_ARG(RenderTicketPtr, ticket),
Q_ARG(bool, prioritize));
AddTicket(ticket);
return ticket;
}
@@ -189,14 +181,7 @@ RenderTicketPtr RenderManager::RenderAudio(ViewerOutput* viewer, const TimeRange
ticket->setProperty("enablewaveforms", generate_waveforms);
ticket->setProperty("aparam", QVariant::fromValue(params));
if (ticket->thread() != this->thread()) {
ticket->moveToThread(this->thread());
}
// Queue appending the ticket and running the next job on our thread to make this function thread-safe
QMetaObject::invokeMethod(this, "AddTicket", Qt::AutoConnection,
OLIVE_NS_ARG(RenderTicketPtr, ticket),
Q_ARG(bool, prioritize));
AddTicket(ticket);
return ticket;
}
@@ -211,20 +196,21 @@ RenderTicketPtr RenderManager::SaveFrameToCache(FrameHashCache *cache, FramePtr
ticket->setProperty("hash", hash);
ticket->setProperty("type", kTypeVideoDownload);
if (ticket->thread() != this->thread()) {
ticket->moveToThread(this->thread());
}
// Queue appending the ticket and running the next job on our thread to make this function thread-safe
QMetaObject::invokeMethod(this, "AddTicket", Qt::AutoConnection,
OLIVE_NS_ARG(RenderTicketPtr, ticket),
Q_ARG(bool, prioritize));
AddTicket(ticket);
return ticket;
}
void RenderManager::RunTicket(RenderTicketPtr ticket) const
{
// Setup the ticket for ::Process
ticket->Start();
if (ticket->IsCancelled()) {
ticket->Finish();
return;
}
RenderProcessor::Process(ticket, context_, decoder_cache_, shader_cache_, default_shader_);
}