From 4a38787d2263ee0566ab1792a8a5366ef82f2a47 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 14 Oct 2017 10:43:32 +0200 Subject: [PATCH] [DEBUG] correct safe thread set name and add back thread priority --- ethread/tools.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/ethread/tools.cpp b/ethread/tools.cpp index 9ab9d78..e8dbeb6 100644 --- a/ethread/tools.cpp +++ b/ethread/tools.cpp @@ -48,21 +48,21 @@ namespace ethread { etk::Map& list = getThreadList(); uint32_t threadID = getThreadHumanId(_id); etk::String out; - // TODO: g_lock.lock(); + g_lock.lock(); auto it = list.find(threadID); if (it != list.end()) { out = it.getValue(); } - // TODO: g_lock.unlock(); + g_lock.unLock(); return out; } void setThreadName(ethread::Thread* _thread, const etk::String& _name) { etk::Map& list = getThreadList(); uint32_t threadID = ethread::getId(); - // TODO: g_lock.lock(); + g_lock.lock(); list.set(threadID, _name); - // TODO: g_lock.unlock(); + g_lock.unLock(); // try now to set the thread name with Pthread #if ( defined(__TARGET_OS__Linux) \ || defined(__TARGET_OS__Android) \ @@ -119,7 +119,6 @@ etk::String ethread::getName(ethread::Thread& _thread) { #if defined(__TARGET_OS__Linux) \ && !defined(__TARGET_OS__Web) static void setThreadPriority(pthread_t _threadID, int32_t _priority) { - #if 0 int retcode; int policy; struct sched_param param; @@ -143,10 +142,8 @@ etk::String ethread::getName(ethread::Thread& _thread) { "???") ); */ } - #endif } static int32_t getThreadPriority(pthread_t _threadID) { - /* int retcode; int policy; struct sched_param param; @@ -159,35 +156,28 @@ etk::String ethread::getName(ethread::Thread& _thread) { return -param.sched_priority; } return param.sched_priority; - */ return 0; } #endif void ethread::setPriority(int32_t _priority) { - /* #if defined(__TARGET_OS__Linux) \ && !defined(__TARGET_OS__Web) pthread_t threadID = pthread_self(); setThreadPriority(threadID, _priority); #endif - */ - } void ethread::setPriority(ethread::Thread& _thread, int32_t _priority) { - /* #if defined(__TARGET_OS__Linux) \ && !defined(__TARGET_OS__Web) - pthread_t threadID = (pthread_t) _thread.native_handle(); + pthread_t threadID = _thread.getNativeHandle(); setThreadPriority(threadID, _priority); #endif - */ } int32_t ethread::getPriority() { - /* #if defined(__TARGET_OS__Linux) \ && !defined(__TARGET_OS__Web) pthread_t threadID = pthread_self(); @@ -195,21 +185,16 @@ int32_t ethread::getPriority() { #else return 20; #endif - */ - return 20; } int32_t ethread::getPriority(ethread::Thread& _thread) { - /* #if defined(__TARGET_OS__Linux) \ && !defined(__TARGET_OS__Web) - pthread_t threadID = static_cast(_thread.native_handle()); + pthread_t threadID = _thread.getNativeHandle(); return getThreadPriority(threadID); #else return 20; #endif - */ - return 20; } //static ethread::Mutex g_localMutex;