MCPcopy Create free account
hub / github.com/brummer10/guitarix / getProcess

Method getProcess

trunk/src/headers/ParallelThread.h:181–201  ·  view source on GitHub ↗

try to get the process pointer, return false when thread is busy

Source from the content-addressed store, hash-verified

179
180 // try to get the process pointer, return false when thread is busy
181 inline bool getProcess() noexcept {
182 if (isRunning() && !getState()) {
183 int maxDuration = 0;
184 while (!getState()) {
185 pthread_mutex_lock(&pWaitProc);
186 if (pthread_cond_timedwait(&pProcCond, &pWaitProc, getTimeOut()) == ETIMEDOUT) {
187 pthread_mutex_unlock(&pWaitProc);
188 maxDuration +=1;
189 //fprintf(stderr, "%s wait for process %i\n", threadName.c_str(), maxDuration);
190 if (maxDuration > 2) {
191 //fprintf(stderr, "%s break waitForProcess\n", threadName.c_str());
192 break;
193 }
194 } else {
195 pthread_mutex_unlock(&pWaitProc);;
196 }
197 }
198 }
199 if (getState()) pWait.store(true, std::memory_order_release);
200 return getState();
201 }
202
203 // notify the thread that work is to be done
204 inline void runProcess() noexcept {

Callers 1

computeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected