History

adjust encoder tasks, add ut and enable new thread pool under some slice modes

Sijia Chen committed 11 years ago

Commit 054a2971 parent 1a7a3e215 files · +330 −44Browse files

Showing the changes to test/common/WelsThreadPoolTest.cpp (1 of 15 files). Show all

Unified · Split

test/common/WelsThreadPoolTest.cpp+54−0
@@ -0,0 +1,54 @@
1+#include <gtest/gtest.h>
2+#include <string.h>
3+#include <string>
4+#include <list>
5+#include <map>
6+
7+#include "typedefs.h"
8+#include "WelsThreadLib.h"
9+#include "WelsThreadPool.h"
10+#include "WelsTask.h"
11+#include "WelsThreadPoolTest.h"
12+
13+#define TEST_TASK_NUM 20
14+
15+class CSimpleTask : public IWelsTask {
16+ public:
17+ static uint32_t id;
18+
19+ CSimpleTask() {
20+ m_uiID = id ++;
21+ }
22+
23+ virtual ~CSimpleTask() {
24+ }
25+
26+ virtual int32_t Execute() {
27+ WelsSleep (300 - m_uiID);
28+ //printf ("Task %d executing\n", m_uiID);
29+ return cmResultSuccess;
30+ }
31+
32+ private:
33+ uint32_t m_uiID;
34+};
35+
36+uint32_t CSimpleTask::id = 0;
37+
38+
39+TEST (CThreadPoolTest, CThreadPoolTest) {
40+ CSimpleTask tasks[TEST_TASK_NUM];
41+ CThreadPoolTest cThreadPoolTest;
42+ CWelsThreadPool cThreadPool (&cThreadPoolTest);
43+
44+ int32_t i;
45+
46+ for (i = 0; i < TEST_TASK_NUM; i++) {
47+ cThreadPool.QueueTask (&tasks[i]);
48+ }
49+
50+ while (cThreadPoolTest.GetTaskCount() < TEST_TASK_NUM) {
51+ WelsSleep (1);
52+ }
53+}
54+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t