ref: 5b8ee37162625cd2260a28a0cd52607cca297217
parent: b4aa9be7deacea66ac820e47abc712cd40e51b9d
author: Martin Storsjö <[email protected]>
date: Mon Mar 3 18:02:30 EST 2014
Merge WelsThreadDestroy into WelsThreadJoin Now calling WelsThreadJoin is enough to finish and clean up the thread on all platforms. This unifies the thread cleanup code between windows and unix. Now all of the threading code should use the exact same codepaths between windows and unix.
--- a/codec/common/WelsThreadLib.cpp
+++ b/codec/common/WelsThreadLib.cpp
@@ -154,19 +154,12 @@
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
WaitForSingleObject (thread, INFINITE);
+ CloseHandle (thread);
return WELS_THREAD_ERROR_OK;
}
-WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread) {
- if (thread != NULL) {
- CloseHandle (*thread);
- *thread = NULL;
- }
- return WELS_THREAD_ERROR_OK;
-}
-
WELS_THREAD_HANDLE WelsThreadSelf() {
return GetCurrentThread();
}
@@ -210,10 +203,6 @@
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
return pthread_join (thread, NULL);
-}
-
-WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread) {
- return WELS_THREAD_ERROR_OK;
}
WELS_THREAD_HANDLE WelsThreadSelf() {
--- a/codec/common/WelsThreadLib.h
+++ b/codec/common/WelsThreadLib.h
@@ -120,8 +120,6 @@
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread);
-WELS_THREAD_ERROR_CODE WelsThreadDestroy (WELS_THREAD_HANDLE* thread);
-
WELS_THREAD_HANDLE WelsThreadSelf();
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2152,19 +2152,7 @@
const int32_t iThreadCount = (*ppCtx)->pSvcParam->iCountThreadsNum;
int32_t iThreadIdx = 0;
-#if defined(_WIN32)
if ((*ppCtx)->pSliceThreading->pExitEncodeEvent != NULL) {
- do {
- if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] != NULL) // iThreadIdx is already created successfully
- WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
- WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
- WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
- ++ iThreadIdx;
- } while (iThreadIdx < iThreadCount);
-
- }
-#else
- if ((*ppCtx)->pSliceThreading->pExitEncodeEvent != NULL) {
while (iThreadIdx < iThreadCount) {
int res = 0;
if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
@@ -2178,7 +2166,6 @@
++ iThreadIdx;
}
}
-#endif//WIN32
}
#endif//MT_ENABLED
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -451,11 +451,6 @@
char ename[SEM_NAME_MAX] = {0};
while (iIdx < iThreadNum) {
// length of semaphore name should be system constrained at least on mac 10.7
-#ifdef _WIN32
- if (pSmt->pThreadHandles != NULL && pSmt->pThreadHandles[iIdx] != NULL)
- WelsThreadDestroy (&pSmt->pThreadHandles[iIdx]);
-
-#endif//_WIN32
WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename);
WelsSnprintf (ename, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace);