From 1d555fdd25fd33a6b14df59dc3291905573f142c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 21:37:08 -0500 Subject: common/thread: Remove unused CurrentThreadId() This is an old function that's no longer necessary. C++11 introduced proper threading support to the language and a thread ID can be retrieved via std::this_thread::get_id() if it's ever needed. --- src/common/thread.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/common/thread.cpp') diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 9e207118f..a7267b637 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -25,16 +25,6 @@ namespace Common { -int CurrentThreadId() { -#ifdef _MSC_VER - return GetCurrentThreadId(); -#elif defined __APPLE__ - return mach_thread_self(); -#else - return 0; -#endif -} - #ifdef _WIN32 // Supporting functions void SleepCurrentThread(int ms) { -- cgit v1.2.3 From d6583d68f630f3bd9a5626ab0fc24f2027ddd50a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 21:40:08 -0500 Subject: common/thread: Remove SleepCurrentThread() This is also unused and superceded by standard functionality. The standard library provides std::this_thread::sleep_for(), which provides a much more flexible interface, as different time units can be used with it. --- src/common/thread.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/common/thread.cpp') diff --git a/src/common/thread.cpp b/src/common/thread.cpp index a7267b637..4bcb65236 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -25,13 +25,6 @@ namespace Common { -#ifdef _WIN32 -// Supporting functions -void SleepCurrentThread(int ms) { - Sleep(ms); -} -#endif - #ifdef _MSC_VER void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { @@ -97,10 +90,6 @@ void SetCurrentThreadAffinity(u32 mask) { } #ifndef _WIN32 -void SleepCurrentThread(int ms) { - usleep(1000 * ms); -} - void SwitchCurrentThread() { usleep(1000 * 1); } -- cgit v1.2.3 From 1bf5a337a599e4be611711881a2b7fdf98baeb72 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 21:53:35 -0500 Subject: common/thread: Drop Hungarian notation on SetCurrentThreadName's parameter This is inconsistent with our coding style. --- src/common/thread.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/common/thread.cpp') diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 4bcb65236..5144c0d9f 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -45,7 +45,7 @@ void SwitchCurrentThread() { // This is implemented much nicer in upcoming msvc++, see: // http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx -void SetCurrentThreadName(const char* szThreadName) { +void SetCurrentThreadName(const char* name) { static const DWORD MS_VC_EXCEPTION = 0x406D1388; #pragma pack(push, 8) @@ -58,7 +58,7 @@ void SetCurrentThreadName(const char* szThreadName) { #pragma pack(pop) info.dwType = 0x1000; - info.szName = szThreadName; + info.szName = name; info.dwThreadID = -1; // dwThreadID; info.dwFlags = 0; @@ -97,15 +97,15 @@ void SwitchCurrentThread() { // MinGW with the POSIX threading model does not support pthread_setname_np #if !defined(_WIN32) || defined(_MSC_VER) -void SetCurrentThreadName(const char* szThreadName) { +void SetCurrentThreadName(const char* name) { #ifdef __APPLE__ - pthread_setname_np(szThreadName); + pthread_setname_np(name); #elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) - pthread_set_name_np(pthread_self(), szThreadName); + pthread_set_name_np(pthread_self(), name); #elif defined(__NetBSD__) - pthread_setname_np(pthread_self(), "%s", (void*)szThreadName); + pthread_setname_np(pthread_self(), "%s", (void*)name); #else - pthread_setname_np(pthread_self(), szThreadName); + pthread_setname_np(pthread_self(), name); #endif } #endif -- cgit v1.2.3