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.
This commit is contained in:
Martin Storsjö 2014-03-03 23:02:30 +02:00
parent b4aa9be7de
commit 5b8ee37162
4 changed files with 1 additions and 32 deletions

View File

@ -154,19 +154,12 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_
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();
}
@ -212,10 +205,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() {
return pthread_self();
}

View File

@ -120,8 +120,6 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_
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);

View File

@ -2152,18 +2152,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
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;
@ -2178,7 +2166,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
++ iThreadIdx;
}
}
#endif//WIN32
}
#endif//MT_ENABLED

View File

@ -451,11 +451,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
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);