diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 601bb0b5b8..d9e0d2da00 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -15,8 +15,9 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include + #include "i18n/i18n.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Common/ChunkFile.h" diff --git a/Core/Dialog/PSPSaveDialog.h b/Core/Dialog/PSPSaveDialog.h index 0e5195c849..460549347b 100644 --- a/Core/Dialog/PSPSaveDialog.h +++ b/Core/Dialog/PSPSaveDialog.h @@ -17,7 +17,8 @@ #pragma once -#include "thread/thread.h" +#include + #include "base/mutex.h" #include "Core/Dialog/PSPDialog.h" #include "Core/Dialog/SavedataParam.h" diff --git a/Core/FileLoaders/CachingFileLoader.cpp b/Core/FileLoaders/CachingFileLoader.cpp index 1b9e269a47..7b8fbcd1c5 100644 --- a/Core/FileLoaders/CachingFileLoader.cpp +++ b/Core/FileLoaders/CachingFileLoader.cpp @@ -15,8 +15,10 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include -#include "thread/thread.h" +#include +#include +#include + #include "thread/threadutil.h" #include "base/timeutil.h" #include "Core/FileLoaders/CachingFileLoader.h" diff --git a/Core/FileLoaders/RamCachingFileLoader.cpp b/Core/FileLoaders/RamCachingFileLoader.cpp index a465aacda6..ab6f435af9 100644 --- a/Core/FileLoaders/RamCachingFileLoader.cpp +++ b/Core/FileLoaders/RamCachingFileLoader.cpp @@ -15,9 +15,10 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include +#include +#include +#include #include "base/timeutil.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Core/FileLoaders/RamCachingFileLoader.h" diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index e03923da5b..1ef7071c0e 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -17,9 +17,10 @@ #pragma once +#include + #include "base/timeutil.h" #include "base/mutex.h" -#include "thread/thread.h" #include "net/resolve.h" #include "Common/ChunkFile.h" diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 0c1e1ecbd6..26f83d1ac7 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -17,8 +17,8 @@ #include #include +#include -#include "thread/thread.h" #include "thread/threadutil.h" #include "profiler/profiler.h" diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index fae7e73078..ed85847fc6 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -28,11 +28,11 @@ #include #include +#include #include "base/basictypes.h" #include "base/mutex.h" #include "profiler/profiler.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Common/Log.h" #include "Core/Config.h" diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 2c0a2ca5d4..2afd721dae 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include + #include "Core/Reporting.h" #include "Common/CPUDetect.h" @@ -38,7 +40,6 @@ #include "base/stringutil.h" #include "base/buffer.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "file/zip_read.h" diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index d39b0dad33..8c9a1d71d5 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -17,11 +17,11 @@ #include #include +#include #include "base/mutex.h" #include "base/timeutil.h" #include "i18n/i18n.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Common/FileUtil.h" diff --git a/Core/System.cpp b/Core/System.cpp index 21d7cb27e3..6c9751995c 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -24,9 +24,9 @@ #include #include #endif +#include #include "math/math_util.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "base/mutex.h" #include "util/text/utf8.h" diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index 69e10110f2..06dbdceb44 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "file/file_util.h" #ifdef SHARED_LIBZIP @@ -25,7 +26,6 @@ #else #include "ext/libzip/zip.h" #endif -#include "thread/thread.h" #include "util/text/utf8.h" #include "Common/Log.h" diff --git a/Core/Util/GameManager.h b/Core/Util/GameManager.h index 4265ed4e14..36e5301c55 100644 --- a/Core/Util/GameManager.h +++ b/Core/Util/GameManager.h @@ -22,7 +22,7 @@ #pragma once -#include "thread/thread.h" +#include #include "net/http_client.h" class GameManager { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index b2ba6ad4ea..edd468b946 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -34,6 +34,7 @@ #include #endif #include +#include #if defined(_WIN32) #include "Windows/DSoundStream.h" @@ -46,7 +47,6 @@ #include "base/NativeApp.h" #include "file/vfs.h" #include "file/zip_read.h" -#include "thread/thread.h" #include "net/http_client.h" #include "gfx_es2/draw_text.h" #include "gfx_es2/gpu_features.h" diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 21a51814cf..d2ee1a37e7 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -15,6 +15,9 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include + #include "base/timeutil.h" #include "ext/vjson/json.h" #include "file/fd_util.h" @@ -23,7 +26,6 @@ #include "net/http_server.h" #include "net/resolve.h" #include "net/sinks.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Common/Common.h" #include "Common/FileUtil.h" diff --git a/Windows/InputDevice.cpp b/Windows/InputDevice.cpp index be9f240ed5..643abeb1f3 100644 --- a/Windows/InputDevice.cpp +++ b/Windows/InputDevice.cpp @@ -16,10 +16,10 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include #include #include "base/mutex.h" #include "input/input_state.h" -#include "thread/thread.h" #include "thread/threadutil.h" #include "Core/Config.h" #include "Core/Host.h" diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index c8ff175c37..27b339c818 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -5,8 +5,8 @@ #include "stdafx.h" #include +#include -#include "thread/thread.h" #include "util/text/utf8.h" #include "ShellUtil.h" #include "CommDlg.h" diff --git a/Windows/W32Util/ShellUtil.h b/Windows/W32Util/ShellUtil.h index 8dcf91d3b3..da5b83ee52 100644 --- a/Windows/W32Util/ShellUtil.h +++ b/Windows/W32Util/ShellUtil.h @@ -2,8 +2,7 @@ #include #include -#include "thread/thread.h" - +#include namespace W32Util { diff --git a/ext/native/native.vcxproj b/ext/native/native.vcxproj index 2431958a14..4e031cb8f7 100644 --- a/ext/native/native.vcxproj +++ b/ext/native/native.vcxproj @@ -273,7 +273,6 @@ - diff --git a/ext/native/native.vcxproj.filters b/ext/native/native.vcxproj.filters index d8e0ec9789..1f4e1baf47 100644 --- a/ext/native/native.vcxproj.filters +++ b/ext/native/native.vcxproj.filters @@ -176,9 +176,6 @@ thread - - thread - thread diff --git a/ext/native/net/http_client.h b/ext/native/net/http_client.h index e23360364d..d7e4a682b6 100644 --- a/ext/native/net/http_client.h +++ b/ext/native/net/http_client.h @@ -2,10 +2,10 @@ #include #include +#include #include "base/basictypes.h" #include "base/buffer.h" -#include "thread/thread.h" #ifdef _WIN32 #ifndef NOMINMAX diff --git a/ext/native/thread/prioritizedworkqueue.cpp b/ext/native/thread/prioritizedworkqueue.cpp index 9a54148d83..754e9b606e 100644 --- a/ext/native/thread/prioritizedworkqueue.cpp +++ b/ext/native/thread/prioritizedworkqueue.cpp @@ -1,8 +1,8 @@ #include +#include #include "base/logging.h" #include "base/timeutil.h" -#include "thread/thread.h" #include "thread/prioritizedworkqueue.h" PrioritizedWorkQueue::~PrioritizedWorkQueue() { diff --git a/ext/native/thread/thread.h b/ext/native/thread/thread.h deleted file mode 100644 index 057afb02c5..0000000000 --- a/ext/native/thread/thread.h +++ /dev/null @@ -1,328 +0,0 @@ - -#ifndef STD_THREAD_H_ -#define STD_THREAD_H_ - -#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z)) -#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) - -#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(__ANDROID__) -// GCC 4.4 provides -#ifndef _GLIBCXX_USE_SCHED_YIELD -#define _GLIBCXX_USE_SCHED_YIELD -#endif -#include -#else - -// partial std::thread implementation for win32/pthread - -#include - -#if (_MSC_VER >= 1600) || (GCC_VERSION >= GCC_VER(4,3,0) && __GXX_EXPERIMENTAL_CXX0X__) -#define USE_RVALUE_REFERENCES -#endif - -//#ifdef __APPLE__ -//#import -//#endif - -#if defined(_WIN32) -// WIN32 - -#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include - -#if defined(_MSC_VER) && defined(_MT) -// When linking with LIBCMT (the multithreaded C library), Microsoft recommends -// using _beginthreadex instead of CreateThread. -#define USE_BEGINTHREADEX -#include -#endif - -#ifdef USE_BEGINTHREADEX -#define THREAD_ID unsigned -#define THREAD_RETURN unsigned __stdcall -#else -#define THREAD_ID DWORD -#define THREAD_RETURN DWORD WINAPI -#endif -#define THREAD_HANDLE HANDLE - -#else -// PTHREAD - -#include - -#ifndef _POSIX_THREADS -#error unsupported platform (no pthreads?) -#endif - -#include - -#define THREAD_ID pthread_t -#define THREAD_HANDLE pthread_t -#define THREAD_RETURN void* - -#endif - -namespace std -{ - -class thread -{ -public: - typedef THREAD_HANDLE native_handle_type; - - class id - { - friend class thread; - public: - id() : m_thread(0) {} - id(THREAD_ID _id) : m_thread(_id) {} - - bool operator==(const id& rhs) const - { - return m_thread == rhs.m_thread; - } - - bool operator!=(const id& rhs) const - { - return !(*this == rhs); - } - - bool operator<(const id& rhs) const - { - return m_thread < rhs.m_thread; - } - - private: - THREAD_ID m_thread; - }; - - // no variadic template support in msvc - //template - //thread(C&& func, A&&... args); - - template - thread(C func) - { - StartThread(new Func(func)); - } - - template - thread(C func, A arg) - { - StartThread(new FuncArg(func, arg)); - } - - thread() /*= default;*/ {} - -#ifdef USE_RVALUE_REFERENCES - thread(const thread&) /*= delete*/; - - thread(thread&& other) - { -#else - thread(const thread& t) - { - // ugly const_cast to get around lack of rvalue references - thread& other = const_cast(t); -#endif - swap(other); - } - -#ifdef USE_RVALUE_REFERENCES - thread& operator=(const thread&) /*= delete*/; - - thread& operator=(thread&& other) - { -#else - thread& operator=(const thread& t) - { - // ugly const_cast to get around lack of rvalue references - thread& other = const_cast(t); -#endif - if (joinable()) - detach(); - swap(other); - return *this; - } - - ~thread() - { - if (joinable()) - detach(); - } - - bool joinable() const - { - return m_id != id(); - } - - id get_id() const - { - return m_id; - } - - native_handle_type native_handle() - { -#ifdef _WIN32 - return m_handle; -#else - return m_id.m_thread; -#endif - } - - void join() - { -#ifdef _WIN32 - WaitForSingleObject(m_handle, INFINITE); - detach(); -#else - pthread_join(m_id.m_thread, NULL); - m_id = id(); -#endif - } - - void detach() - { -#ifdef _WIN32 - CloseHandle(m_handle); -#else - pthread_detach(m_id.m_thread); -#endif - m_id = id(); - } - - void swap(thread& other) - { - std::swap(m_id, other.m_id); -#ifdef _WIN32 - std::swap(m_handle, other.m_handle); -#endif - } - - static unsigned hardware_concurrency() - { -#ifdef _WIN32 - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - return static_cast(sysinfo.dwNumberOfProcessors); -#else - return 0; -#endif - } - -private: - id m_id; - -#ifdef _WIN32 - native_handle_type m_handle; -#endif - - template - void StartThread(F* param) - { -#ifdef USE_BEGINTHREADEX - m_handle = (HANDLE)_beginthreadex(NULL, 0, &RunAndDelete, param, 0, &m_id.m_thread); -#elif defined(_WIN32) - m_handle = CreateThread(NULL, 0, &RunAndDelete, param, 0, &m_id.m_thread); -#else - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, 1024 * 1024); - if (pthread_create(&m_id.m_thread, &attr, &RunAndDelete, param)) - m_id = id(); -#endif - } - - template - class Func - { - public: - Func(C _func) : func(_func) {} - - void Run() { func(); } - - private: -// Both Visual Studio 2012 & 2013 need the following ifdef, or else they complain about losing const-volatile qualifiers: -// Error 23 error C3848: expression having type 'const std::_Bind' would lose some const-volatile qualifiers in order to call 'void std::_Bind::operator ()<>(void)' (thread\prioritizedworkqueue.cpp) - -// Error 24 error C3848: expression having type 'const std::_Bind,WorkerThread *const >' -// would lose some const-volatile qualifiers in order to call -// 'void std::_Bind,WorkerThread *const >::operator ()<>(void)' (thread\threadpool.cpp) - -// Error 25 error C3848 : expression having type 'const std::_Bind),void,http::Download,std::shared_ptr>,http::Download *const ,std::shared_ptr &>' -// would lose some const - volatile qualifiers in order to call -// 'void std::_Bind),void,http::Download,std::shared_ptr>,http::Download *const ,std::shared_ptr &>::operator ()<>(void)' (net\http_client.cpp) -#if _MSC_VER >= 1700 - C func; -#else - C const func; -#endif - }; - - template - class FuncArg - { - public: - FuncArg(C _func, A _arg) : func(_func), arg(_arg) {} - - void Run() { func(arg); } - - private: - C const func; - A arg; - }; - - template - static THREAD_RETURN RunAndDelete(void* param) - { -#ifdef __APPLE__ - // NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -#endif - static_cast(param)->Run(); - delete static_cast(param); -#ifdef __APPLE__ - // [pool release]; -#endif - return 0; - } -}; - -namespace this_thread -{ - -inline void yield() -{ -#ifdef _WIN32 - SwitchToThread(); -#else - sleep(0); -#endif -} - -inline thread::id get_id() -{ -#ifdef _WIN32 - return GetCurrentThreadId(); -#else - return pthread_self(); -#endif -} - -} // namespace this_thread - -} // namespace std - -#undef USE_RVALUE_REFERENCES -#undef USE_BEGINTHREADEX -#undef THREAD_ID -#undef THREAD_RETURN -#undef THREAD_HANDLE - -#endif -#endif diff --git a/ext/native/thread/threadpool.h b/ext/native/thread/threadpool.h index 8bb0b2964a..1844f5e7c0 100644 --- a/ext/native/thread/threadpool.h +++ b/ext/native/thread/threadpool.h @@ -3,8 +3,8 @@ #include #include #include +#include -#include "thread.h" #include "base/mutex.h" // This is the simplest possible worker implementation I can think of