From 2e475b8059e3267a2371e3fda5bba66fdf040055 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Mon, 1 Jun 2020 14:54:08 +0200 Subject: [PATCH] add first draft of thread priority --- forms/advanced-scene-switcher.ui | 49 ++++++++++++++++++++++++++- src/advanced-scene-switcher.cpp | 5 ++- src/headers/switcher-data-structs.hpp | 13 +++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/forms/advanced-scene-switcher.ui b/forms/advanced-scene-switcher.ui index 12d12b74..17cad277 100644 --- a/forms/advanced-scene-switcher.ui +++ b/forms/advanced-scene-switcher.ui @@ -7,7 +7,7 @@ 0 0 981 - 457 + 492 @@ -336,6 +336,53 @@ + + + + Qt::Horizontal + + + + + + + + + Use thread priority (experimental) + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index 70e5ef49..574497a4 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -400,6 +400,10 @@ SceneSwitcher::SceneSwitcher(QWidget *parent) new QListWidgetItem(text, ui->priorityList); item->setData(Qt::UserRole, text); } + + for (std::string p : switcher->threadPrioritiesNamesOrderdByPrio) { + ui->threadPriority->addItem(p.c_str()); + } } /******************************************************************************** @@ -1382,7 +1386,6 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *) ********************************************************************************/ void SwitcherData::Thread() { - //to avoid scene duplication when rapidly switching scene collection this_thread::sleep_for(chrono::seconds(2)); diff --git a/src/headers/switcher-data-structs.hpp b/src/headers/switcher-data-structs.hpp index 2aae300b..26b86e06 100644 --- a/src/headers/switcher-data-structs.hpp +++ b/src/headers/switcher-data-structs.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "utility.hpp" #define DEFAULT_INTERVAL 300 @@ -308,6 +309,18 @@ struct SwitcherData { DEFAULT_PRIORITY_3, DEFAULT_PRIORITY_4, DEFAULT_PRIORITY_5, DEFAULT_PRIORITY_6, DEFAULT_PRIORITY_7}; + std::vector threadPrioritiesNamesOrderdByPrio{ + "Lowest", "Low", "Normal", "High", "Highest", "Time critical", + }; + std::map threadPriorities = { + {"Lowest", QThread::LowestPriority}, + {"Low", QThread::LowPriority}, + {"Normal", QThread::NormalPriority}, + {"High", QThread::HighPriority}, + {"Highest", QThread::HighestPriority}, + {"Time critical", QThread::TimeCriticalPriority}, + }; + void Thread(); void Start(); void Stop();