History

fix low memory crash issue

huili2 committed 9 years ago

Commit d1c0a931 parent 48c2fe116 files · +401 −386Browse files

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

Unified · Split

test/common/WelsThreadPoolTest.cpp+15−11
@@ -39,7 +39,9 @@ uint32_t CSimpleTask::id = 0; · 38 unmodified lines
39void* OneCallingFunc() {39void* OneCallingFunc() {
40 CThreadPoolTest cThreadPoolTest;40 CThreadPoolTest cThreadPoolTest;
41 CSimpleTask* aTasks[TEST_TASK_NUM];41 CSimpleTask* aTasks[TEST_TASK_NUM];
42 CWelsThreadPool* pThreadPool = & (CWelsThreadPool::AddReference());42 CWelsThreadPool* pThreadPool = (CWelsThreadPool::AddReference());
43 if (pThreadPool == NULL)
44 return 0;
43 45
44 int32_t i;46 int32_t i;
45 for (i = 0; i < TEST_TASK_NUM; i++) {47 for (i = 0; i < TEST_TASK_NUM; i++) {
@@ -70,8 +72,10 @@ TEST (CThreadPoolTest, CThreadPoolTest) { · 24 unmodified lines
70 EXPECT_EQ (0, iRet);72 EXPECT_EQ (0, iRet);
71 EXPECT_FALSE (CWelsThreadPool::IsReferenced());73 EXPECT_FALSE (CWelsThreadPool::IsReferenced());
72 74
73 CWelsThreadPool* pThreadPool = & (CWelsThreadPool::AddReference ());75 CWelsThreadPool* pThreadPool = (CWelsThreadPool::AddReference());
74 EXPECT_TRUE(pThreadPool->IsReferenced());76 ASSERT_TRUE (pThreadPool != NULL);
77
78 EXPECT_TRUE (pThreadPool->IsReferenced());
75 79
76 EXPECT_EQ (8, pThreadPool->GetThreadNum());80 EXPECT_EQ (8, pThreadPool->GetThreadNum());
77 81
@@ -84,7 +88,7 @@ TEST (CThreadPoolTest, CThreadPoolTest) { · 6 unmodified lines
84 iRet = CWelsThreadPool::SetThreadNum (4);88 iRet = CWelsThreadPool::SetThreadNum (4);
85 EXPECT_EQ (0, iRet);89 EXPECT_EQ (0, iRet);
86 90
87 pThreadPool = & (CWelsThreadPool::AddReference ());91 pThreadPool = (CWelsThreadPool::AddReference());
88 EXPECT_TRUE (pThreadPool->IsReferenced());92 EXPECT_TRUE (pThreadPool->IsReferenced());
89 EXPECT_EQ (4, pThreadPool->GetThreadNum());93 EXPECT_EQ (4, pThreadPool->GetThreadNum());
90 pThreadPool->RemoveInstance();94 pThreadPool->RemoveInstance();
@@ -97,24 +101,24 @@ TEST (CThreadPoolTest, CThreadPoolTestMulti) { · 6 unmodified lines
97 int iCallingNum = 10;101 int iCallingNum = 10;
98 WELS_THREAD_HANDLE mThreadID[30];102 WELS_THREAD_HANDLE mThreadID[30];
99 int i = 0;103 int i = 0;
100 104 WELS_THREAD_ERROR_CODE rc;
101 for (i = 0; i < iCallingNum; i++) {105 for (i = 0; i < iCallingNum; i++) {
102 WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);106 rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
107 ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
103 WelsSleep (1);108 WelsSleep (1);
104 }109 }
105
106 for (i = iCallingNum; i < iCallingNum * 2; i++) {110 for (i = iCallingNum; i < iCallingNum * 2; i++) {
107 WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);111 rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
112 ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
108 WelsSleep (1);113 WelsSleep (1);
109 WelsThreadJoin (mThreadID[i]);114 WelsThreadJoin (mThreadID[i]);
110 }115 }
111
112 for (i = 0; i < iCallingNum; i++) {116 for (i = 0; i < iCallingNum; i++) {
113 WelsThreadJoin (mThreadID[i]);117 WelsThreadJoin (mThreadID[i]);
114 }118 }
115
116 for (i = iCallingNum * 2; i < iCallingNum * 3; i++) {119 for (i = iCallingNum * 2; i < iCallingNum * 3; i++) {
117 WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);120 rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
121 ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
118 WelsSleep (1);122 WelsSleep (1);
119 WelsThreadJoin (mThreadID[i]);123 WelsThreadJoin (mThreadID[i]);
120 }124 }

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