ref: 757a596e97d91a3b55644ce5eca1d8e72e218a1d
parent: af6a9a838fa18a827ea5684b72374ccf9f0e6ddb
author: Sijia Chen <sijchen@cisco.com>
date: Thu Oct 15 06:04:00 EDT 2015
add basic threadpool functions https://rbcommons.com/s/OpenH264/r/1294/
--- a/codec/build/iOS/common/common.xcodeproj/project.pbxproj
+++ b/codec/build/iOS/common/common.xcodeproj/project.pbxproj
@@ -7,6 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
+ 0DD32A861B467902009181A1 /* WelsThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD32A851B467902009181A1 /* WelsThread.cpp */; };
+ 0DD32A881B467911009181A1 /* WelsTaskThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD32A871B467911009181A1 /* WelsTaskThread.cpp */; };
+ 0DD32A941B468F77009181A1 /* WelsThreadPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD32A931B468F77009181A1 /* WelsThreadPool.cpp */; };
4C3406C918D96EA600DFA14A /* arm_arch_common_macro.S in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406B218D96EA600DFA14A /* arm_arch_common_macro.S */; };
4C3406CA18D96EA600DFA14A /* deblocking_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406B318D96EA600DFA14A /* deblocking_neon.S */; };
4C3406CB18D96EA600DFA14A /* expand_picture_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406B418D96EA600DFA14A /* expand_picture_neon.S */; };
@@ -46,6 +49,14 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 0DD32A851B467902009181A1 /* WelsThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WelsThread.cpp; sourceTree = "<group>"; };
+ 0DD32A871B467911009181A1 /* WelsTaskThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WelsTaskThread.cpp; sourceTree = "<group>"; };
+ 0DD32A8E1B467B83009181A1 /* WelsLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsLock.h; sourceTree = "<group>"; };
+ 0DD32A8F1B467C73009181A1 /* WelsTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsTask.h; sourceTree = "<group>"; };
+ 0DD32A901B467C73009181A1 /* WelsTaskThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsTaskThread.h; sourceTree = "<group>"; };
+ 0DD32A911B467C73009181A1 /* WelsThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsThread.h; sourceTree = "<group>"; };
+ 0DD32A921B467C73009181A1 /* WelsThreadPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelsThreadPool.h; sourceTree = "<group>"; };
+ 0DD32A931B468F77009181A1 /* WelsThreadPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WelsThreadPool.cpp; sourceTree = "<group>"; };
4C3406B218D96EA600DFA14A /* arm_arch_common_macro.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = arm_arch_common_macro.S; sourceTree = "<group>"; };
4C3406B318D96EA600DFA14A /* deblocking_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = deblocking_neon.S; sourceTree = "<group>"; };
4C3406B418D96EA600DFA14A /* expand_picture_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = expand_picture_neon.S; sourceTree = "<group>"; };
@@ -134,6 +145,11 @@
5BD896B81A7B837700D32B7D /* memory_align.h */,
4C3406C118D96EA600DFA14A /* typedefs.h */,
5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */,
+ 0DD32A8E1B467B83009181A1 /* WelsLock.h */,
+ 0DD32A8F1B467C73009181A1 /* WelsTask.h */,
+ 0DD32A901B467C73009181A1 /* WelsTaskThread.h */,
+ 0DD32A911B467C73009181A1 /* WelsThread.h */,
+ 0DD32A921B467C73009181A1 /* WelsThreadPool.h */,
5B9196F91A7F8BA40075D641 /* wels_const_common.h */,
4C3406C218D96EA600DFA14A /* WelsThreadLib.h */,
);
@@ -153,6 +169,9 @@
4C3406C618D96EA600DFA14A /* deblocking_common.cpp */,
5BDD15EC1A79027600B6CA2E /* mc.cpp */,
5BD896B91A7B839B00D32B7D /* memory_align.cpp */,
+ 0DD32A871B467911009181A1 /* WelsTaskThread.cpp */,
+ 0DD32A931B468F77009181A1 /* WelsThreadPool.cpp */,
+ 0DD32A851B467902009181A1 /* WelsThread.cpp */,
4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */,
);
path = src;
@@ -260,6 +279,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 0DD32A941B468F77009181A1 /* WelsThreadPool.cpp in Sources */,
F5B8D82D190757290037849A /* mc_aarch64_neon.S in Sources */,
4C3406C918D96EA600DFA14A /* arm_arch_common_macro.S in Sources */,
F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */,
@@ -268,8 +288,10 @@
4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */,
F791965919D3BE2200F60C6B /* intra_pred_common.cpp in Sources */,
5BD896BA1A7B839B00D32B7D /* memory_align.cpp in Sources */,
+ 0DD32A881B467911009181A1 /* WelsTaskThread.cpp in Sources */,
4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */,
5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */,
+ 0DD32A861B467902009181A1 /* WelsThread.cpp in Sources */,
F791965419D3B89D00F60C6B /* intra_pred_common_aarch64_neon.S in Sources */,
4C3406D118D96EA600DFA14A /* WelsThreadLib.cpp in Sources */,
4C3406CC18D96EA600DFA14A /* mc_neon.S in Sources */,
--- a/codec/build/win32/enc/WelsEncCore.vcproj
+++ b/codec/build/win32/enc/WelsEncCore.vcproj
@@ -474,7 +474,19 @@
>
</File>
<File
+ RelativePath="..\..\..\common\src\WelsTaskThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\src\WelsThread.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\common\src\WelsThreadLib.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\src\WelsThreadPool.cpp"
>
</File>
</Filter>
--- /dev/null
+++ b/codec/common/inc/WelsLock.h
@@ -1,0 +1,97 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsLock.h
+ *
+ * \brief class wrapping for locks
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+#ifndef _WELS_LOCK_H_
+#define _WELS_LOCK_H_
+
+#include "macros.h"
+#include "typedefs.h"
+#include "WelsThreadLib.h"
+
+namespace WelsCommon {
+
+class CWelsLock {
+ DISALLOW_COPY_AND_ASSIGN (CWelsLock);
+ public:
+ CWelsLock() {
+ WelsMutexInit (&m_cMutex);
+ }
+
+ virtual ~CWelsLock() {
+ WelsMutexDestroy (&m_cMutex);
+ }
+
+ WELS_THREAD_ERROR_CODE Lock() {
+ return WelsMutexLock (&m_cMutex);
+ }
+
+ WELS_THREAD_ERROR_CODE Unlock() {
+ return WelsMutexUnlock (&m_cMutex);
+ }
+
+ private:
+ WELS_MUTEX m_cMutex;
+};
+
+class CWelsAutoLock {
+ DISALLOW_COPY_AND_ASSIGN (CWelsAutoLock);
+ public:
+ CWelsAutoLock (CWelsLock& cLock) : m_cLock (cLock) {
+ m_cLock.Lock();
+ }
+
+ virtual ~CWelsAutoLock() {
+ m_cLock.Unlock();
+ }
+
+ private:
+ CWelsLock& m_cLock;
+};
+
+}
+
+#endif
+
+
+
+
+
+
+
--- /dev/null
+++ b/codec/common/inc/WelsTask.h
@@ -1,0 +1,59 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsThreadPool.h
+ *
+ * \brief Interfaces introduced in thread pool
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+#ifndef _WELS_TASK_H_
+#define _WELS_TASK_H_
+
+#include "codec_def.h"
+
+namespace WelsCommon {
+
+class IWelsTask {
+ public:
+ virtual ~IWelsTask() { }
+
+ virtual CM_RETURN Execute() = 0;
+};
+
+}
+
+#endif
+
+
--- /dev/null
+++ b/codec/common/inc/WelsTaskThread.h
@@ -1,0 +1,83 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsTaskThread.h
+ *
+ * \brief connecting task and thread
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+
+#ifndef _WELS_TASK_THREAD_H_
+#define _WELS_TASK_THREAD_H_
+
+
+#include "WelsTask.h"
+#include "WelsThread.h"
+
+namespace WelsCommon {
+
+class CWelsTaskThread;
+
+class IWelsTaskThreadSink {
+ public:
+ virtual WELS_THREAD_ERROR_CODE OnTaskStart (CWelsTaskThread* pThread, IWelsTask* pTask) = 0;
+ virtual WELS_THREAD_ERROR_CODE OnTaskStop (CWelsTaskThread* pThread, IWelsTask* pTask) = 0;
+};
+
+class CWelsTaskThread : public CWelsThread {
+ public:
+ CWelsTaskThread (IWelsTaskThreadSink* pSink);
+ virtual ~CWelsTaskThread();
+
+ WELS_THREAD_ERROR_CODE SetTask (IWelsTask* pTask);
+ virtual void ExecuteTask();
+
+ uintptr_t GetID() const {
+ return m_uiID;
+ }
+
+ private:
+ CWelsLock m_cLockTask;
+ IWelsTaskThreadSink* m_pSink;
+ IWelsTask* m_pTask;
+ uintptr_t m_uiID;
+
+ DISALLOW_COPY_AND_ASSIGN (CWelsTaskThread);
+};
+
+}
+
+#endif
+
--- /dev/null
+++ b/codec/common/inc/WelsThread.h
@@ -1,0 +1,105 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsThread.h
+ *
+ * \brief Interfaces introduced in threads
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+
+#ifndef _WELS_THREAD_H_
+#define _WELS_THREAD_H_
+
+
+#include "macros.h"
+#include "WelsLock.h"
+#include "WelsThreadLib.h"
+
+namespace WelsCommon {
+
+class CWelsThread {
+ public:
+ CWelsThread();
+ virtual ~CWelsThread();
+
+ virtual void Thread();
+ virtual void ExecuteTask() = 0;
+ virtual WELS_THREAD_ERROR_CODE Start();
+ virtual void Kill();
+
+ protected:
+ static WELS_THREAD_ROUTINE_TYPE TheThread (void* pParam);
+
+ void SetRunning (bool bRunning) {
+ CWelsAutoLock cLock (m_cLockStatus);
+
+ m_bRunning = bRunning;
+ }
+ void SetEndFlag (bool bEndFlag) {
+ CWelsAutoLock cLock (m_cLockStatus);
+
+ m_bEndFlag = bEndFlag;
+ }
+
+ bool GetRunning() const {
+ return m_bRunning;
+ }
+
+ bool GetEndFlag() const {
+ return m_bEndFlag;
+ }
+
+ void SignalThread() {
+ WelsEventSignal (&m_hEvent);
+ }
+
+ private:
+ WELS_THREAD_HANDLE m_hThread;
+ WELS_EVENT m_hEvent;
+ CWelsLock m_cLockStatus;
+ bool m_bRunning;
+ bool m_bEndFlag;
+
+ DISALLOW_COPY_AND_ASSIGN (CWelsThread);
+};
+
+
+}
+
+
+
+#endif
+
+
--- a/codec/common/inc/WelsThreadLib.h
+++ b/codec/common/inc/WelsThreadLib.h
@@ -104,8 +104,9 @@
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
-WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name);
-WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name);
+WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name = NULL);
+WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name = NULL);
+
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event);
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds);
@@ -125,6 +126,7 @@
WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo);
+void WelsSleep (uint32_t dwMilliSecond);
#ifdef __cplusplus
}
--- /dev/null
+++ b/codec/common/inc/WelsThreadPool.h
@@ -1,0 +1,118 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsThreadPool.h
+ *
+ * \brief Interfaces introduced in thread pool
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+
+#ifndef _WELS_THREAD_POOL_H_
+#define _WELS_THREAD_POOL_H_
+
+#include <map>
+
+#include "WelsTask.h"
+#include "WelsTaskThread.h"
+
+namespace WelsCommon {
+
+class IWelsThreadPoolSink {
+ public:
+ virtual WELS_THREAD_ERROR_CODE OnTaskExecuted (IWelsTask* pTask) = 0;
+ virtual WELS_THREAD_ERROR_CODE OnTaskCancelled (IWelsTask* pTask) = 0;
+};
+
+
+class CWelsThreadPool : public CWelsThread, public IWelsTaskThreadSink {
+ public:
+ enum {
+ DEFAULT_THREAD_NUM = 4,
+ };
+
+ CWelsThreadPool (IWelsThreadPoolSink* pSink = NULL, int32_t iMaxThreadNum = DEFAULT_THREAD_NUM);
+ virtual ~CWelsThreadPool();
+
+ //IWelsTaskThreadSink
+ virtual WELS_THREAD_ERROR_CODE OnTaskStart (CWelsTaskThread* pThread, IWelsTask* pTask);
+ virtual WELS_THREAD_ERROR_CODE OnTaskStop (CWelsTaskThread* pThread, IWelsTask* pTask);
+
+ // CWelsThread
+ virtual void ExecuteTask();
+
+ WELS_THREAD_ERROR_CODE QueueTask (IWelsTask* pTask);
+ int32_t GetThreadNum() const {
+ return m_iMaxThreadNum;
+ }
+
+ protected:
+ WELS_THREAD_ERROR_CODE Init (int32_t iMaxThreadNum = DEFAULT_THREAD_NUM);
+ WELS_THREAD_ERROR_CODE Uninit();
+
+ WELS_THREAD_ERROR_CODE CreateIdleThread();
+ void DestroyThread (CWelsTaskThread* pThread);
+ WELS_THREAD_ERROR_CODE AddThreadToIdleMap (CWelsTaskThread* pThread);
+ WELS_THREAD_ERROR_CODE AddThreadToBusyMap (CWelsTaskThread* pThread);
+ WELS_THREAD_ERROR_CODE RemoveThreadFromBusyMap (CWelsTaskThread* pThread);
+ void AddTaskToWaitedList (IWelsTask* pTask);
+ CWelsTaskThread* GetIdleThread();
+ IWelsTask* GetWaitedTask();
+ int32_t GetIdleThreadNum();
+ int32_t GetBusyThreadNum();
+ int32_t GetWaitedTaskNum();
+ void ClearWaitedTasks();
+
+ private:
+ int32_t m_iMaxThreadNum;
+ std::list<IWelsTask*> m_cWaitedTasks;
+ std::map<uintptr_t, CWelsTaskThread*> m_cIdleThreads;
+ std::map<uintptr_t, CWelsTaskThread*> m_cBusyThreads;
+ IWelsThreadPoolSink* m_pSink;
+
+ CWelsLock m_cLockPool;
+ CWelsLock m_cLockWaitedTasks;
+ CWelsLock m_cLockIdleTasks;
+ CWelsLock m_cLockBusyTasks;
+
+ DISALLOW_COPY_AND_ASSIGN (CWelsThreadPool);
+};
+
+}
+
+
+#endif
+
+
+
--- a/codec/common/inc/macros.h
+++ b/codec/common/inc/macros.h
@@ -205,6 +205,11 @@
return iX;
}
+#define DISALLOW_COPY_AND_ASSIGN(cclass) \
+private: \
+cclass(const cclass &); \
+cclass& operator=(const cclass &);
+
/*
* Description: to check variable validation and return the specified result
* iResult: value to be checked
--- /dev/null
+++ b/codec/common/src/WelsTaskThread.cpp
@@ -1,0 +1,89 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsTaskThread.cpp
+ *
+ * \brief functions for TaskThread
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+
+
+#include "WelsTaskThread.h"
+
+namespace WelsCommon {
+
+CWelsTaskThread::CWelsTaskThread (IWelsTaskThreadSink* pSink) : m_pSink (pSink) {
+ m_uiID = (uintptr_t) (this);
+ m_pTask = NULL;
+}
+
+
+CWelsTaskThread::~CWelsTaskThread() {
+}
+
+void CWelsTaskThread::ExecuteTask() {
+ CWelsAutoLock cLock (m_cLockTask);
+ if (m_pSink) {
+ m_pSink->OnTaskStart (this, m_pTask);
+ }
+
+ if (m_pTask) {
+ m_pTask->Execute();
+ }
+
+ if (m_pSink) {
+ m_pSink->OnTaskStop (this, m_pTask);
+ }
+
+ m_pTask = NULL;
+}
+
+WELS_THREAD_ERROR_CODE CWelsTaskThread::SetTask (WelsCommon::IWelsTask* pTask) {
+ CWelsAutoLock cLock (m_cLockTask);
+
+ if (!GetRunning()) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ m_pTask = pTask;
+
+ SignalThread();
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+
+}
+
--- /dev/null
+++ b/codec/common/src/WelsThread.cpp
@@ -1,0 +1,125 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsThreadPool.cpp
+ *
+ * \brief functions for Thread Pool
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+#include "WelsThread.h"
+
+namespace WelsCommon {
+
+CWelsThread::CWelsThread() :
+ m_hThread (0),
+ m_bRunning (false),
+ m_bEndFlag (false) {
+ WELS_THREAD_ERROR_CODE rc = WelsEventOpen (&m_hEvent);
+
+ if (WELS_THREAD_ERROR_OK != rc) {
+ m_hEvent = NULL;
+ }
+}
+
+CWelsThread::~CWelsThread() {
+ Kill();
+ WelsEventClose (&m_hEvent);
+ m_hEvent = NULL;
+}
+
+void CWelsThread::Thread() {
+ while (true) {
+ WelsEventWait (&m_hEvent);
+
+ if (GetEndFlag()) {
+ break;
+ }
+
+ ExecuteTask();
+ }
+
+ SetRunning (false);
+}
+
+WELS_THREAD_ERROR_CODE CWelsThread::Start() {
+ if (NULL == m_hEvent) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ if (GetRunning()) {
+ return WELS_THREAD_ERROR_OK;
+ }
+
+ SetEndFlag (false);
+
+ WELS_THREAD_ERROR_CODE rc = WelsThreadCreate (&m_hThread,
+ (LPWELS_THREAD_ROUTINE)TheThread, this, 0);
+
+ if (WELS_THREAD_ERROR_OK != rc) {
+ return rc;
+ }
+
+ while (!GetRunning()) {
+ WelsSleep (1);
+ }
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+void CWelsThread::Kill() {
+ if (!GetRunning()) {
+ return;
+ }
+
+ SetEndFlag (true);
+
+ WelsEventSignal (&m_hEvent);
+ WelsThreadJoin (m_hThread);
+ return;
+}
+
+WELS_THREAD_ROUTINE_TYPE CWelsThread::TheThread (void* pParam) {
+ CWelsThread* pThis = static_cast<CWelsThread*> (pParam);
+
+ pThis->SetRunning (true);
+
+ pThis->Thread();
+
+ WELS_THREAD_ROUTINE_RETURN (NULL);
+}
+
+}
+
+
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -274,8 +274,14 @@
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {
#ifdef __APPLE__
- if (p_event == NULL || event_name == NULL)
+ if (p_event == NULL) {
return WELS_THREAD_ERROR_GENERAL;
+ }
+ char strSuffix[16] = { 0 };
+ if (NULL == event_name) {
+ sprintf (strSuffix, "WelsSem%ld_p%ld", (intptr_t)p_event, (long) (getpid()));
+ event_name = &strSuffix[0];
+ }
*p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);
if (*p_event == (sem_t*)SEM_FAILED) {
sem_unlink (event_name);
@@ -321,8 +327,16 @@
return err;
}
-WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
+WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
return sem_wait (*event); // blocking until signaled
+}
+
+void WelsSleep (uint32_t dwMilliSecond) {
+#ifdef WIN32
+ ::Sleep (dwMilliSecond);
+#else
+ usleep (dwMilliSecond * 1000);
+#endif
}
WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
--- /dev/null
+++ b/codec/common/src/WelsThreadPool.cpp
@@ -1,0 +1,305 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2015, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file WelsThreadPool.cpp
+ *
+ * \brief functions for Thread Pool
+ *
+ * \date 5/09/2012 Created
+ *
+ *************************************************************************************
+ */
+
+
+#include <list>
+#include <map>
+
+#include "typedefs.h"
+#include "WelsThreadPool.h"
+
+namespace WelsCommon {
+
+
+CWelsThreadPool::CWelsThreadPool (IWelsThreadPoolSink* pSink, int32_t iMaxThreadNum) :
+ m_pSink (pSink) {
+ m_iMaxThreadNum = 0;
+
+ Init (iMaxThreadNum);
+}
+
+
+CWelsThreadPool::~CWelsThreadPool() {
+ Uninit();
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::OnTaskStart (CWelsTaskThread* pThread, IWelsTask* pTask) {
+ AddThreadToBusyMap (pThread);
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::OnTaskStop (CWelsTaskThread* pThread, IWelsTask* pTask) {
+ RemoveThreadFromBusyMap (pThread);
+ AddThreadToIdleMap (pThread);
+
+ if (m_pSink) {
+ m_pSink->OnTaskExecuted (pTask);
+ }
+
+ //WELS_INFO_TRACE("ThreadPool: Task "<<(uint32_t)pTask<<" Finished, Thread "<<(uint32_t)pThread<<" put to idle list");
+
+ SignalThread();
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::Init (int32_t iMaxThreadNum) {
+ CWelsAutoLock cLock (m_cLockPool);
+ //WELS_INFO_TRACE("Enter WelsThreadPool Init");
+
+ int32_t i;
+
+ if (iMaxThreadNum <= 0) iMaxThreadNum = 1;
+ m_iMaxThreadNum = iMaxThreadNum;
+
+ for (i = 0; i < m_iMaxThreadNum; i++) {
+ if (WELS_THREAD_ERROR_OK != CreateIdleThread()) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+ }
+
+ if (WELS_THREAD_ERROR_OK != Start()) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::Uninit() {
+ WELS_THREAD_ERROR_CODE iReturn = WELS_THREAD_ERROR_OK;
+ CWelsAutoLock cLock (m_cLockPool);
+
+ ClearWaitedTasks();
+
+ while (GetBusyThreadNum() > 0) {
+ //WELS_INFO_TRACE ("CWelsThreadPool::Uninit - Waiting all thread to exit");
+ WelsSleep (10);
+ }
+
+ if (GetIdleThreadNum() != m_iMaxThreadNum) {
+ iReturn = WELS_THREAD_ERROR_GENERAL;
+ }
+
+ m_cLockIdleTasks.Lock();
+ std::map<uintptr_t, CWelsTaskThread*>::iterator iter = m_cIdleThreads.begin();
+ while (iter != m_cIdleThreads.end()) {
+ DestroyThread (iter->second);
+ ++ iter;
+ }
+ m_cLockIdleTasks.Unlock();
+
+ m_iMaxThreadNum = 0;
+ Kill();
+
+ return iReturn;
+}
+
+void CWelsThreadPool::ExecuteTask() {
+ //WELS_INFO_TRACE("ThreadPool: schedule tasks");
+ CWelsTaskThread* pThread = NULL;
+ IWelsTask* pTask = NULL;
+ while (GetWaitedTaskNum() > 0) {
+ pThread = GetIdleThread();
+ if (pThread == NULL) {
+ break;
+ }
+ pTask = GetWaitedTask();
+ //WELS_INFO_TRACE("ThreadPool: ExecuteTask = "<<(uint32_t)(pTask)<<" at thread = "<<(uint32_t)(pThread));
+ pThread->SetTask (pTask);
+ }
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::QueueTask (IWelsTask* pTask) {
+ CWelsAutoLock cLock (m_cLockPool);
+
+ //WELS_INFO_TRACE("ThreadPool: QueueTask = "<<(uint32_t)(pTask));
+ if (GetWaitedTaskNum() == 0) {
+ CWelsTaskThread* pThread = GetIdleThread();
+
+ if (pThread != NULL) {
+ //WELS_INFO_TRACE("ThreadPool: ExecuteTask = "<<(uint32_t)(pTask));
+ pThread->SetTask (pTask);
+
+ return WELS_THREAD_ERROR_OK;
+ }
+ }
+
+ AddTaskToWaitedList (pTask);
+
+ SignalThread();
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::CreateIdleThread() {
+ CWelsTaskThread* pThread = new CWelsTaskThread (this);
+
+ if (NULL == pThread) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ pThread->Start();
+ AddThreadToIdleMap (pThread);
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+void CWelsThreadPool::DestroyThread (CWelsTaskThread* pThread) {
+ pThread->Kill();
+ delete pThread;
+
+ return;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::AddThreadToIdleMap (CWelsTaskThread* pThread) {
+ CWelsAutoLock cLock (m_cLockIdleTasks);
+
+ uintptr_t id = pThread->GetID();
+
+ std::map<uintptr_t, CWelsTaskThread*>::iterator iter = m_cIdleThreads.find (id);
+
+ if (iter != m_cIdleThreads.end()) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ m_cIdleThreads[id] = pThread;
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::AddThreadToBusyMap (CWelsTaskThread* pThread) {
+ CWelsAutoLock cLock (m_cLockBusyTasks);
+
+ uintptr_t id = pThread->GetID();
+
+ std::map<uintptr_t, CWelsTaskThread*>::iterator iter = m_cBusyThreads.find (id);
+
+ if (iter != m_cBusyThreads.end()) {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ m_cBusyThreads[id] = pThread;
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+WELS_THREAD_ERROR_CODE CWelsThreadPool::RemoveThreadFromBusyMap (CWelsTaskThread* pThread) {
+ CWelsAutoLock cLock (m_cLockBusyTasks);
+
+ uintptr_t id = pThread->GetID();
+
+ std::map<uintptr_t, CWelsTaskThread*>::iterator iter = m_cBusyThreads.find (id);
+
+ if (iter != m_cBusyThreads.end()) {
+ m_cBusyThreads.erase (iter);
+ } else {
+ return WELS_THREAD_ERROR_GENERAL;
+ }
+
+ return WELS_THREAD_ERROR_OK;
+}
+
+void CWelsThreadPool::AddTaskToWaitedList (IWelsTask* pTask) {
+ CWelsAutoLock cLock (m_cLockWaitedTasks);
+
+ m_cWaitedTasks.push_back (pTask);
+ return;
+}
+
+CWelsTaskThread* CWelsThreadPool::GetIdleThread() {
+ CWelsAutoLock cLock (m_cLockIdleTasks);
+
+ if (m_cIdleThreads.size() == 0) {
+ return NULL;
+ }
+
+ std::map<uintptr_t, CWelsTaskThread*>::iterator it = m_cIdleThreads.begin();
+ CWelsTaskThread* pThread = it->second;
+
+ m_cIdleThreads.erase (it);
+
+ return pThread;
+}
+
+int32_t CWelsThreadPool::GetBusyThreadNum() {
+ return static_cast<int32_t> (m_cBusyThreads.size());
+}
+
+int32_t CWelsThreadPool::GetIdleThreadNum() {
+ return static_cast<int32_t> (m_cIdleThreads.size());
+}
+
+int32_t CWelsThreadPool::GetWaitedTaskNum() {
+ return static_cast<int32_t> (m_cWaitedTasks.size());
+}
+
+IWelsTask* CWelsThreadPool::GetWaitedTask() {
+ CWelsAutoLock lock (m_cLockWaitedTasks);
+
+ if (m_cWaitedTasks.size() == 0) {
+ return NULL;
+ }
+
+ std::list<IWelsTask*>::iterator it = m_cWaitedTasks.begin();
+ IWelsTask* pTask = *it;
+
+ m_cWaitedTasks.pop_front();
+
+ return pTask;
+}
+
+void CWelsThreadPool::ClearWaitedTasks() {
+ CWelsAutoLock cLock (m_cLockWaitedTasks);
+
+ std::list<IWelsTask*>::iterator iter = m_cWaitedTasks.begin();
+
+ if (m_pSink) {
+ while (iter != m_cWaitedTasks.end()) {
+ m_pSink->OnTaskCancelled (*iter);
+ ++ iter;
+ }
+ }
+
+ m_cWaitedTasks.clear();
+}
+
+}
+
+
--- a/codec/common/targets.mk
+++ b/codec/common/targets.mk
@@ -12,7 +12,10 @@
$(COMMON_SRCDIR)/src/sad_common.cpp\
$(COMMON_SRCDIR)/src/utils.cpp\
$(COMMON_SRCDIR)/src/welsCodecTrace.cpp\
+ $(COMMON_SRCDIR)/src/WelsTaskThread.cpp\
+ $(COMMON_SRCDIR)/src/WelsThread.cpp\
$(COMMON_SRCDIR)/src/WelsThreadLib.cpp\
+ $(COMMON_SRCDIR)/src/WelsThreadPool.cpp\
COMMON_OBJS += $(COMMON_CPP_SRCS:.cpp=.$(OBJ))