diff --git a/CMakeLists.txt b/CMakeLists.txt index f0eb5da521..9f498bc890 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -597,8 +597,6 @@ add_library(Common STATIC Common/Render/Text/draw_text_uwp.h Common/System/Display.cpp Common/System/Display.h - Common/Thread/Executor.cpp - Common/Thread/Executor.h Common/Thread/PrioritizedWorkQueue.cpp Common/Thread/PrioritizedWorkQueue.h Common/Thread/ThreadUtil.cpp diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 8029db0faa..7595b60f80 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -523,7 +523,6 @@ - @@ -860,7 +859,6 @@ - diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index c83818b6bd..dd834136fc 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -102,9 +102,6 @@ Thread - - Thread - Input @@ -494,9 +491,6 @@ Thread - - Thread - Input diff --git a/Common/Net/HTTPServer.cpp b/Common/Net/HTTPServer.cpp index 1deb45f72c..9eee85d3fb 100644 --- a/Common/Net/HTTPServer.cpp +++ b/Common/Net/HTTPServer.cpp @@ -37,11 +37,21 @@ #include "Common/Net/HTTPServer.h" #include "Common/Net/Sinks.h" #include "Common/File/FileDescriptor.h" -#include "Common/Thread/Executor.h" #include "Common/Buffer.h" #include "Common/Log.h" +void NewThreadExecutor::Run(std::function &&func) { + threads_.push_back(std::thread(func)); +} + +NewThreadExecutor::~NewThreadExecutor() { + // If Run was ever called... + for (auto &thread : threads_) + thread.join(); + threads_.clear(); +} + namespace http { // Note: charset here helps prevent XSS. @@ -126,7 +136,7 @@ void Request::Close() { } } -Server::Server(threading::Executor *executor) +Server::Server(NewThreadExecutor *executor) : port_(0), executor_(executor) { RegisterHandler("/", std::bind(&Server::HandleListing, this, std::placeholders::_1)); SetFallbackHandler(std::bind(&Server::Handle404, this, std::placeholders::_1)); diff --git a/Common/Net/HTTPServer.h b/Common/Net/HTTPServer.h index 9cfdf2fc1e..1a5e1f9b62 100644 --- a/Common/Net/HTTPServer.h +++ b/Common/Net/HTTPServer.h @@ -2,10 +2,19 @@ #include #include +#include #include "Common/Net/HTTPHeaders.h" #include "Common/Net/Resolve.h" -#include "Common/Thread/Executor.h" + +class NewThreadExecutor { +public: + ~NewThreadExecutor(); + void Run(std::function &&func); + +private: + std::vector threads_; +}; namespace net { class InputSink; @@ -61,7 +70,7 @@ private: class Server { public: // Takes ownership. - Server(threading::Executor *executor); + Server(NewThreadExecutor *executor); virtual ~Server(); typedef std::function UrlHandlerFunc; @@ -108,7 +117,7 @@ private: UrlHandlerMap handlers_; UrlHandlerFunc fallback_; - threading::Executor *executor_; + NewThreadExecutor *executor_; }; } // namespace http diff --git a/Common/Thread/Executor.cpp b/Common/Thread/Executor.cpp deleted file mode 100644 index 6f9c689103..0000000000 --- a/Common/Thread/Executor.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "Common/Thread/Executor.h" - -#include -#include - -namespace threading { - -void SameThreadExecutor::Run(std::function func) { - func(); -} - -void NewThreadExecutor::Run(std::function func) { - threads_.push_back(std::thread(func)); -} - -NewThreadExecutor::~NewThreadExecutor() { - // If Run was ever called... - for (auto &thread : threads_) - thread.join(); - threads_.clear(); -} - -} // namespace threading diff --git a/Common/Thread/Executor.h b/Common/Thread/Executor.h deleted file mode 100644 index 44924952e6..0000000000 --- a/Common/Thread/Executor.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace threading { - -// Stuff that can execute other stuff, like threadpools, should inherit from this. -class Executor { -public: - virtual void Run(std::function func) = 0; - virtual ~Executor() {} -}; - -class SameThreadExecutor : public Executor { -public: - void Run(std::function func) override; -}; - -class NewThreadExecutor : public Executor { -public: - ~NewThreadExecutor() override; - void Run(std::function func) override; - -private: - std::vector threads_; -}; - -} // namespace threading diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index ade556a563..2ee8d840bd 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -249,7 +249,7 @@ static void ForwardDebuggerRequest(const http::Request &request) { static void ExecuteWebServer() { setCurrentThreadName("HTTPServer"); - auto http = new http::Server(new threading::NewThreadExecutor()); + auto http = new http::Server(new NewThreadExecutor()); http->RegisterHandler("/", &HandleListing); // This lists all the (current) recent ISOs. http->SetFallbackHandler(&HandleFallback); diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index f1d57b3acc..b408128a15 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -483,7 +483,6 @@ - @@ -591,7 +590,6 @@ - diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 95b4f0d0bd..c15bfcac05 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -178,9 +178,6 @@ Input - - Thread - Thread @@ -453,9 +450,6 @@ Input - - Thread - Thread diff --git a/android/jni/Android.mk b/android/jni/Android.mk index ba47a09f49..f3281da7b5 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -279,7 +279,6 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Common/Net/WebsocketServer.cpp \ $(SRC)/Common/Profiler/Profiler.cpp \ $(SRC)/Common/System/Display.cpp \ - $(SRC)/Common/Thread/Executor.cpp \ $(SRC)/Common/Thread/PrioritizedWorkQueue.cpp \ $(SRC)/Common/Thread/ThreadPool.cpp \ $(SRC)/Common/Thread/ThreadUtil.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 8e09571052..881021e6fd 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -204,7 +204,6 @@ SOURCES_CXX += \ $(COMMONDIR)/Render/DrawBuffer.cpp \ $(COMMONDIR)/Render/TextureAtlas.cpp \ $(COMMONDIR)/Serialize/Serializer.cpp \ - $(COMMONDIR)/Thread/Executor.cpp \ $(COMMONDIR)/Thread/ThreadUtil.cpp \ $(COMMONDIR)/Thread/ThreadPool.cpp \ $(COMMONDIR)/Thread/PrioritizedWorkQueue.cpp \