62
62
63
63
#if defined(_WIN32)
64
64
#define MINGW_STDTHREAD_REDUNDANCY_WARNING
65
+ #include < windows.h>
65
66
#endif
66
67
67
68
#include < atomic>
@@ -108,6 +109,8 @@ class ProcessPtr
108
109
void process () const {
109
110
return memberFunc[i](instPtr[i]);
110
111
}
112
+
113
+ void dummyFunc () {}
111
114
112
115
private:
113
116
typedef void * InstancePtr;
@@ -118,8 +121,6 @@ class ProcessPtr
118
121
return (static_cast <C*>(instance)->*Function)();
119
122
}
120
123
121
- void dummyFunc () {}
122
-
123
124
InstancePtr instPtr[2 ];
124
125
MemberFunc memberFunc[2 ];
125
126
uint32_t i;
@@ -185,9 +186,7 @@ class ParallelThread: public ProcessPtr
185
186
if (pthread_cond_timedwait (&pProcCond, &pWaitProc, getTimeOut ()) == ETIMEDOUT) {
186
187
pthread_mutex_unlock (&pWaitProc);
187
188
maxDuration +=1 ;
188
- // fprintf(stderr, "%s wait for process %i\n", threadName.c_str(), maxDuration);
189
189
if (maxDuration > 2 ) {
190
- // fprintf(stderr, "%s break waitForProcess\n", threadName.c_str());
191
190
break ;
192
191
}
193
192
} else {
@@ -219,16 +218,13 @@ class ParallelThread: public ProcessPtr
219
218
if (pthread_cond_timedwait (&pProcCond, &pWaitProc, getTimeOut ()) == ETIMEDOUT) {
220
219
pthread_mutex_unlock (&pWaitProc);
221
220
maxDuration +=1 ;
222
- // fprintf(stderr, "%s wait for data %i\n", threadName.c_str(), maxDuration);
223
221
if (maxDuration > 5 ) {
224
222
pWait.store (false , std::memory_order_release);
225
- // fprintf(stderr, "%s break processWait\n", threadName.c_str());
226
223
}
227
224
} else {
228
225
pthread_mutex_unlock (&pWaitProc);;
229
226
}
230
227
}
231
- // fprintf(stderr, "%s processed data %i\n", threadName.c_str(), maxDuration);
232
228
}
233
229
}
234
230
@@ -237,6 +233,7 @@ class ParallelThread: public ProcessPtr
237
233
if (isRunning ()) {
238
234
pRun.store (false , std::memory_order_release);
239
235
if (pThd.joinable ()) {
236
+ set<ProcessPtr, &ProcessPtr::dummyFunc>(this );
240
237
#if __cplusplus > 201703L
241
238
pWorkCond.store (true );
242
239
#endif
0 commit comments