2015-10-28 17:39:26 +01:00
|
|
|
#ifndef _WELS_THREAD_POOL_TEST_H_
|
|
|
|
#define _WELS_THREAD_POOL_TEST_H_
|
|
|
|
|
2015-11-04 19:29:08 +01:00
|
|
|
#include "WelsLock.h"
|
2015-10-28 17:39:26 +01:00
|
|
|
#include "WelsThreadPool.h"
|
|
|
|
|
|
|
|
using namespace WelsCommon;
|
|
|
|
|
2016-03-03 02:08:09 +01:00
|
|
|
class CThreadPoolTest : public IWelsTaskSink {
|
2015-10-28 17:39:26 +01:00
|
|
|
public:
|
|
|
|
CThreadPoolTest() {
|
|
|
|
m_iTaskCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
~CThreadPoolTest() {}
|
|
|
|
|
|
|
|
virtual int32_t OnTaskExecuted (IWelsTask* pTask) {
|
2015-11-04 19:29:08 +01:00
|
|
|
WelsCommon::CWelsAutoLock cAutoLock (m_cTaskCountLock);
|
2015-10-28 17:39:26 +01:00
|
|
|
m_iTaskCount ++;
|
2016-01-14 07:13:43 +01:00
|
|
|
//fprintf(stdout, "Task execute over count is %d\n", m_iTaskCount);
|
2015-10-28 17:39:26 +01:00
|
|
|
return cmResultSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int32_t OnTaskCancelled (IWelsTask* pTask) {
|
2015-11-04 19:29:08 +01:00
|
|
|
WelsCommon::CWelsAutoLock cAutoLock (m_cTaskCountLock);
|
2015-10-28 17:39:26 +01:00
|
|
|
m_iTaskCount ++;
|
2016-01-14 07:13:43 +01:00
|
|
|
//fprintf(stdout, "Task execute cancelled count is %d\n", m_iTaskCount);
|
2015-10-28 17:39:26 +01:00
|
|
|
return cmResultSuccess;
|
|
|
|
}
|
|
|
|
|
2016-02-29 20:40:25 +01:00
|
|
|
virtual int32_t OnTaskExecuted() {
|
2016-01-14 01:24:54 +01:00
|
|
|
WelsCommon::CWelsAutoLock cAutoLock (m_cTaskCountLock);
|
|
|
|
m_iTaskCount ++;
|
2016-01-14 07:13:43 +01:00
|
|
|
//fprintf(stdout, "Task execute over count is %d\n", m_iTaskCount);
|
2016-01-14 01:24:54 +01:00
|
|
|
return cmResultSuccess;
|
|
|
|
}
|
|
|
|
|
2016-02-29 20:40:25 +01:00
|
|
|
virtual int32_t OnTaskCancelled() {
|
2016-01-14 01:24:54 +01:00
|
|
|
WelsCommon::CWelsAutoLock cAutoLock (m_cTaskCountLock);
|
|
|
|
m_iTaskCount ++;
|
2016-01-14 07:13:43 +01:00
|
|
|
//fprintf(stdout, "Task execute cancelled count is %d\n", m_iTaskCount);
|
2016-01-14 01:24:54 +01:00
|
|
|
return cmResultSuccess;
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:39:26 +01:00
|
|
|
int32_t GetTaskCount() {
|
|
|
|
return m_iTaskCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int32_t m_iTaskCount;
|
2015-11-04 19:29:08 +01:00
|
|
|
WelsCommon::CWelsLock m_cTaskCountLock;
|
2015-10-28 17:39:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|