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