[osx/ios] fixed, m_machThreadPort was not init'ed correctly, refactor it out and...
authordavilla <davilla@4pi.com>
Fri, 11 May 2012 23:49:19 +0000 (19:49 -0400)
committerdavilla <davilla@4pi.com>
Fri, 11 May 2012 23:50:10 +0000 (19:50 -0400)
xbmc/linux/XHandle.cpp
xbmc/linux/XHandle.h
xbmc/threads/Thread.h
xbmc/threads/platform/pthreads/ThreadImpl.cpp

index 52f540a..25980ff 100644 (file)
@@ -110,9 +110,6 @@ void CXHandle::Init()
   m_nRefCount=1;
   m_tmCreation = time(NULL);
   m_internalLock = new CCriticalSection();
-#ifdef __APPLE__
-  m_machThreadPort = 0;
-#endif
 }
 
 void CXHandle::ChangeType(HandleType newType) {
index dd7f37d..89f93bb 100644 (file)
@@ -49,13 +49,6 @@ public:
   XbmcThreads::ConditionVariable     *m_hCond;
   std::list<CXHandle*>  m_hParents;
 
-#ifdef __APPLE__
-  // Save the Mach thrad port, I don't think it can be obtained from
-  // the pthread_t. We'll use it for querying timer information.
-  //
-  mach_port_t m_machThreadPort;
-#endif
-
   // simulate mutex and critical section
   CCriticalSection *m_hMutex;
   int       RecursionCount;  // for mutex - for compatibility with WIN32 critical section
index 80caa32..051217c 100644 (file)
@@ -129,12 +129,4 @@ private:
   float m_fLastUsage;
 
   std::string m_ThreadName;
-
-#ifdef __APPLE__
-  // Save the Mach thrad port, I don't think it can be obtained from
-  // the pthread_t. We'll use it for querying timer information.
-  //
-  mach_port_t m_machThreadPort;
-#endif
-
 };
index 71b2099..04c7c1d 100644 (file)
@@ -196,23 +196,19 @@ int64_t CThread::GetAbsoluteUsage()
   
   int64_t time = 0;
 #ifdef TARGET_DARWIN
-  thread_info_data_t     threadInfo;
-  mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
+  thread_basic_info threadInfo;
+  mach_msg_type_number_t threadInfoCount = THREAD_BASIC_INFO_COUNT;
 
-  if (m_machThreadPort == MACH_PORT_NULL)
-    m_machThreadPort = pthread_mach_thread_np(m_ThreadId);
-
-  kern_return_t ret = thread_info(m_machThreadPort, THREAD_BASIC_INFO, (thread_info_t)threadInfo, &threadInfoCount);
+  kern_return_t ret = thread_info(pthread_mach_thread_np(m_ThreadId),
+    THREAD_BASIC_INFO, (thread_info_t)&threadInfo, &threadInfoCount);
 
   if (ret == KERN_SUCCESS)
   {
-    thread_basic_info_t threadBasicInfo = (thread_basic_info_t)threadInfo;
-
     // User time.
-    time = ((int64_t)threadBasicInfo->user_time.seconds * 10000000L) + threadBasicInfo->user_time.microseconds*10L;
+    time = ((int64_t)threadInfo.user_time.seconds * 10000000L) + threadInfo.user_time.microseconds*10L;
 
     // System time.
-    time += (((int64_t)threadBasicInfo->system_time.seconds * 10000000L) + threadBasicInfo->system_time.microseconds*10L);
+    time += (((int64_t)threadInfo.system_time.seconds * 10000000L) + threadInfo.system_time.microseconds*10L);
   }
 
 #else