From bf7503fe5c209e7adc76c9b665014a53faf90f2b Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Mon, 21 Jul 2014 09:56:24 -0700
Subject: [PATCH] Remove the automation thread priority stuff

It hasn't actually been used for anything for a while, and if a single
normal-priority thread can make your system unresponsive it's time to
upgrade to an OS that's isn't garbage.
---
 libaegisub/include/libaegisub/background_runner.h | 3 +--
 src/auto4_base.cpp                                | 8 +-------
 src/dialog_progress.cpp                           | 2 +-
 src/dialog_progress.h                             | 2 +-
 src/libresrc/default_config.json                  | 1 -
 src/libresrc/osx/default_config.json              | 1 -
 src/preferences.cpp                               | 4 ----
 7 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/libaegisub/include/libaegisub/background_runner.h b/libaegisub/include/libaegisub/background_runner.h
index ee0298cbd..29bd8efcb 100644
--- a/libaegisub/include/libaegisub/background_runner.h
+++ b/libaegisub/include/libaegisub/background_runner.h
@@ -68,13 +68,12 @@ namespace agi {
 
 		/// @brief Run a function on a background thread
 		/// @param task Function to run
-		/// @param priority Thread priority or -1 for default
 		/// @throws agi::UserCancelException on cancel
 		///
 		/// Blocks the calling thread until the task completes or is canceled.
 		/// Progress updates sent to the progress sink passed to the task should
 		/// be displayed to the user in some way, along with some way for the
 		/// user to cancel the task.
-		virtual void Run(std::function<void(ProgressSink *)> task, int priority=-1)=0;
+		virtual void Run(std::function<void(ProgressSink *)> task)=0;
 	};
 }
diff --git a/src/auto4_base.cpp b/src/auto4_base.cpp
index dd11ba837..b5fa2e53d 100644
--- a/src/auto4_base.cpp
+++ b/src/auto4_base.cpp
@@ -239,16 +239,10 @@ namespace Automation4 {
 
 	void BackgroundScriptRunner::Run(std::function<void (ProgressSink*)> task)
 	{
-		int prio = OPT_GET("Automation/Thread Priority")->GetInt();
-		if (prio == 0) prio = 50; // normal
-		else if (prio == 1) prio = 30; // below normal
-		else if (prio == 2) prio = 10; // lowest
-		else prio = 50; // fallback normal
-
 		impl->Run([&](agi::ProgressSink *ps) {
 			ProgressSink aps(ps, this);
 			task(&aps);
-		}, prio);
+		});
 	}
 
 	wxWindow *BackgroundScriptRunner::GetParentWindow() const
diff --git a/src/dialog_progress.cpp b/src/dialog_progress.cpp
index d09efb1db..53a79e7fa 100644
--- a/src/dialog_progress.cpp
+++ b/src/dialog_progress.cpp
@@ -143,7 +143,7 @@ DialogProgress::DialogProgress(wxWindow *parent, wxString const& title_text, wxS
 	Bind(wxEVT_TIMER, [=](wxTimerEvent&) { gauge->Pulse(); });
 }
 
-void DialogProgress::Run(std::function<void(agi::ProgressSink*)> task, int priority) {
+void DialogProgress::Run(std::function<void(agi::ProgressSink*)> task) {
 	DialogProgressSink ps(this);
 	this->ps = &ps;
 
diff --git a/src/dialog_progress.h b/src/dialog_progress.h
index d6891b8b0..d4e4667d0 100644
--- a/src/dialog_progress.h
+++ b/src/dialog_progress.h
@@ -64,5 +64,5 @@ public:
 	DialogProgress(wxWindow *parent, wxString const& title="", wxString const& message="");
 
 	/// BackgroundWorker implementation
-	void Run(std::function<void(agi::ProgressSink *)> task, int priority=-1) override;
+	void Run(std::function<void(agi::ProgressSink *)> task) override;
 };
diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json
index 4c2b22931..c541ca16e 100644
--- a/src/libresrc/default_config.json
+++ b/src/libresrc/default_config.json
@@ -94,7 +94,6 @@
 
 	"Automation" : {
 		"Autoreload Mode" : 1,
-		"Thread Priority" : 1,
 		"Trace Level" : 3
 	},
 
diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json
index 5fc6a4a66..3e0617216 100644
--- a/src/libresrc/osx/default_config.json
+++ b/src/libresrc/osx/default_config.json
@@ -94,7 +94,6 @@
 
 	"Automation" : {
 		"Autoreload Mode" : 1,
-		"Thread Priority" : 1,
 		"Trace Level" : 3
 	},
 
diff --git a/src/preferences.cpp b/src/preferences.cpp
index e1c2b190c..bd635fad0 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -324,10 +324,6 @@ void Automation(wxTreebook *book, Preferences *parent) {
 	wxArrayString tl_choice(6, tl_arr);
 	p->OptionChoice(general, _("Trace level"), tl_choice, "Automation/Trace Level");
 
-	const wxString tp_arr[3] = { _("Normal"), _("Below Normal (recommended)"), _("Lowest") };
-	wxArrayString tp_choice(3, tp_arr);
-	p->OptionChoice(general, _("Thread priority"), tp_choice, "Automation/Thread Priority");
-
 	const wxString ar_arr[4] = { _("No scripts"), _("Subtitle-local scripts"), _("Global autoload scripts"), _("All scripts") };
 	wxArrayString ar_choice(4, ar_arr);
 	p->OptionChoice(general, _("Autoreload on Export"), ar_choice, "Automation/Autoreload Mode");
-- 
GitLab