History

fix potential deadlock prob in multi-thread

sijchen@cisco.com committed 9 years ago

Commit c51a4ff1 parent 4484df46 files · +65 −26Browse files

Showing the changes to codec/common/src/WelsThread.cpp (1 of 6 files). Show all

Unified · Split

codec/common/src/WelsThread.cpp+5−4
@@ -49,7 +49,7 @@ CWelsThread::CWelsThread() : · 48 unmodified lines
49 49
50 WelsEventOpen (&m_hEvent);50 WelsEventOpen (&m_hEvent);
51 WelsMutexInit(&m_hMutex);51 WelsMutexInit(&m_hMutex);
52 52 m_iConVar = 1;
53}53}
54 54
55CWelsThread::~CWelsThread() {55CWelsThread::~CWelsThread() {
@@ -60,13 +60,14 @@ CWelsThread::~CWelsThread() { · 4 unmodified lines
60 60
61void CWelsThread::Thread() {61void CWelsThread::Thread() {
62 while (true) {62 while (true) {
63 WelsEventWait (&m_hEvent,&m_hMutex);63 WelsEventWait (&m_hEvent,&m_hMutex,m_iConVar);
64 64
65 if (GetEndFlag()) {65 if (GetEndFlag()) {
66 break;66 break;
67 }67 }
68 68
69 ExecuteTask();69 m_iConVar = 1;
70 ExecuteTask();//in ExecuteTask there will be OnTaskStop which opens the potential new Signaling of next run, so the setting of m_iConVar = 1 should be before ExecuteTask()
70 }71 }
71 72
72 SetRunning (false);73 SetRunning (false);
@@ -105,7 +106,7 @@ void CWelsThread::Kill() { · 32 unmodified lines
105 106
106 SetEndFlag (true);107 SetEndFlag (true);
107 108
108 WelsEventSignal (&m_hEvent);109 WelsEventSignal (&m_hEvent,&m_hMutex,&m_iConVar);
109 WelsThreadJoin (m_hThread);110 WelsThreadJoin (m_hThread);
110 return;111 return;
111}112}

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