ArchThread ArchMultithreadPosix::newCurrentThread() { lockMutex(m_threadMutex); ArchThreadImpl* thread = find(pthread_self()); unlockMutex(m_threadMutex); assert(thread != NULL); return thread; }
void Multiplier_::in(Generator& generator){ lockMutex(); inputs.push_back(generator); if ( generator.isStereoOutput() && !this->isStereoOutput() ){ this->setIsStereoOutput(true); workSpace.resize(kSynthesisBlockSize, 2, 0); } unlockMutex(); }
ArchThread ArchMultithreadWindows::newCurrentThread() { lockMutex(m_threadMutex); ArchThreadImpl* thread = find(GetCurrentThreadId()); unlockMutex(m_threadMutex); assert(thread != NULL); return thread; }
void SQLMXLoggingArea::logCompNQCretryEvent(const char *stmt) { bool lockedMutex = lockMutex(); QRLogger::log(QRLogger::instance().getMyDefaultCat(), LL_ALERT, "Statement was compiled as if query plan caching were off: %s", stmt); if (lockedMutex) unlockMutex(); }
void SQLMXLoggingArea::logSQLMXPredefinedEvent(const char *msg, logLevel level) { bool lockedMutex = lockMutex(); QRLogger::log(QRLogger::instance().getMyDefaultCat(), level, "%s ", msg); if (lockedMutex) unlockMutex(); }
void SQLMXLoggingArea::logSQLMXDebugEvent(const char *msg, short errorcode, bool lock) { bool lockedMutex = lock ? lockMutex() : false; QRLogger::log(QRLogger::instance().getMyDefaultCat(), LL_DEBUG, "%s ", msg); if (lockedMutex) unlockMutex(); }
void SQLMXLoggingArea::logMVRefreshInfoEvent(const char *msg) { bool lockedMutex = lockMutex(); QRLogger::log(CAT_SQL_COMP_MV_REFRESH, LL_INFO, "%s", msg); if (lockedMutex) unlockMutex(); }
void releasePipe(char* name){ lockMutex(pipeMutex); int pos = whereIsPipe(name); if(pos!=-1){ deletePipe(pipes[pos]); pipes[pos]=0; } unlockMutex(pipeMutex); }
void ArchMultithreadPosix::setSignalHandler( ESignal signal, SignalFunc func, void* userData) { lockMutex(m_threadMutex); m_signalFunc[signal] = func; m_signalUserData[signal] = userData; unlockMutex(m_threadMutex); }
void setListenerThreadStatus( PAPIConnection * inConnection, PAPIListenerThreadStatus inStatus ) { if ( lockMutex(inConnection->mListenerThreadStatusMutex ) == 0 ) { inConnection->mListenerThreadStatus = inStatus; unlockMutex( inConnection->mListenerThreadStatusMutex ); } }
void Core::updateCore() { frames++; frameTicks = getTicks(); elapsed = frameTicks - lastFrameTicks; if(elapsed > 1000) elapsed = 1000; if(fixedElapsed > 0) { timeLeftOver = fixedElapsed; } else { timeLeftOver = 0; } fixedElapsed = (((Number)elapsed)/1000.0f) + timeLeftOver; if(fixedElapsed > maxFixedElapsed) { fixedElapsed = maxFixedElapsed; } if(coreResized) { coreResized = false; dispatchEvent(new Event(), EVENT_CORE_RESIZE); } services->Update(elapsed); if(frameTicks-lastFPSTicks >= 1000) { fps = frames; frames = 0; lastFPSTicks = frameTicks; } lastFrameTicks = frameTicks; if(threadedEventMutex){ lockMutex(threadedEventMutex); std::vector<Threaded*>::iterator iter = threads.begin(); while (iter != threads.end()) { for(int j=0; j < (*iter)->eventQueue.size(); j++) { Event *event = (*iter)->eventQueue[j]; (*iter)->__dispatchEvent(event, event->getEventCode()); if(event->deleteOnDispatch) delete event; } (*iter)->eventQueue.clear(); if((*iter)->scheduledForRemoval) { iter = threads.erase(iter); } else { ++iter; } } unlockMutex(threadedEventMutex); } }
void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect) { lockMutex(); if (!this->m_sizeavailable) { updateGauss(); } void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; }
void waitCondition(condition_t *p_cond, mutex_t *p_mutex) { uint8_t irEnabled = enterAtomicBlock(); unlockMutex(p_mutex); waitSignal(&(p_cond->signal)); exitAtomicBlock(irEnabled); lockMutex(p_mutex); }
void *BokehBlurOperation::initializeTileData(rcti * /*rect*/) { lockMutex(); if (!this->m_sizeavailable) { updateSize(); } void *buffer = getInputOperation(0)->initializeTileData(NULL); unlockMutex(); return buffer; }
ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void* data) { assert(func != NULL); // initialize signal handler. we do this here instead of the // constructor so we can avoid daemonizing (using fork()) // when there are multiple threads. clients can safely // use condition variables and mutexes before creating a // new thread and they can safely use the only thread // they have access to, the main thread, so they really // can't tell the difference. if (!m_newThreadCalled) { m_newThreadCalled = true; #if HAVE_PTHREAD_SIGNAL startSignalHandler(); #endif } lockMutex(m_threadMutex); // create thread impl for new thread ArchThreadImpl* thread = new ArchThreadImpl; thread->m_func = func; thread->m_userData = data; // create the thread. pthread_create() on RedHat 7.2 smp fails // if passed a NULL attr so use a default attr. pthread_attr_t attr; int status = pthread_attr_init(&attr); if (status == 0) { status = pthread_create(&thread->m_thread, &attr, &ArchMultithreadPosix::threadFunc, thread); pthread_attr_destroy(&attr); } // check if thread was started if (status != 0) { // failed to start thread so clean up delete thread; thread = NULL; } else { // add thread to list insert(thread); // increment ref count to account for the thread itself refThread(thread); } // note that the child thread will wait until we release this mutex unlockMutex(m_threadMutex); return thread; }
bool ArchMultithreadPosix::wait(ArchThread target, double timeout) { assert(target != NULL); lockMutex(m_threadMutex); // find current thread ArchThreadImpl* self = findNoRef(pthread_self()); // ignore wait if trying to wait on ourself if (target == self) { unlockMutex(m_threadMutex); return false; } // ref the target so it can't go away while we're watching it refThread(target); unlockMutex(m_threadMutex); try { // do first test regardless of timeout testCancelThreadImpl(self); if (isExitedThread(target)) { closeThread(target); return true; } // wait and repeat test if there's a timeout if (timeout != 0.0) { const double start = ARCH->time(); do { // wait a little ARCH->sleep(0.05); // repeat test testCancelThreadImpl(self); if (isExitedThread(target)) { closeThread(target); return true; } // repeat wait and test until timed out } while (timeout < 0.0 || (ARCH->time() - start) <= timeout); } closeThread(target); return false; } catch (...) { closeThread(target); throw; } }
PAPIListenerThreadStatus getListenerThreadStatus( PAPIConnection * inConnection ) { PAPIListenerThreadStatus theListenerThreadStatus = NOT_RUNNING; if ( lockMutex( inConnection->mListenerThreadStatusMutex ) == 0 ) { theListenerThreadStatus = inConnection->mListenerThreadStatus; unlockMutex( inConnection->mListenerThreadStatusMutex ); } return theListenerThreadStatus; }
void SQLMXLoggingArea::logExecRtInfo(const char *fileName, ULng32 lineNo, const char *msgTxt, Lng32 explainSeqNum) { bool lockedMutex = lockMutex(); QRLogger::log(QRLogger::instance().getMyDefaultCat(), LL_INFO, "%s Explain Sequence Number: %d FILE: %s LINE: %d", msgTxt, explainSeqNum, fileName, lineNo); if (lockedMutex) unlockMutex(); }
bool tryPop(T& returnedElement) { std::lock_guard<std::mutex> lockMutex(mtx); while (dataQueue.empty()) { return false; } returnedElement = std::move(dataQueue.front()); dataQueue.pop(); return true; }
void Core::createThread(Threaded *target) { if(!threadedEventMutex) { threadedEventMutex = createMutex(); } target->eventMutex = threadedEventMutex; target->core = this; lockMutex(threadedEventMutex); threads.push_back(target); unlockMutex(threadedEventMutex); }
int readPipe(pipe_t pipe,char* ans,uint64_t amount){ int j,i; lockMutex(pipe->readMutex); while (pipe->bufferSize <= 0){ waitCondVar(&pipe->readCondVar,pipe->readMutex); } lockMutex(pipe->mutex); for(j=0;j<amount && pipe->bufferSize>0;j++){ ans[j]=pipe->buffer[pipe->initialIndex%MINPAGE]; pipe->initialIndex = (pipe->initialIndex + 1)%MINPAGE; pipe->bufferSize--; } signalCondVar(&pipe->writeCondVar); unlockMutex(pipe->mutex); unlockMutex(pipe->readMutex); return 1; }
void ArchMultithreadWindows::testCancelThread() { // find current thread lockMutex(m_threadMutex); ArchThreadImpl* thread = findNoRef(GetCurrentThreadId()); unlockMutex(m_threadMutex); // test cancel on thread testCancelThreadImpl(thread); }
void ArchMultithreadPosix::testCancelThread() { // find current thread lockMutex(m_threadMutex); ArchThreadImpl* thread = findNoRef(pthread_self()); unlockMutex(m_threadMutex); // test cancel on thread testCancelThreadImpl(thread); }
void *KeyingScreenOperation::initializeTileData(rcti *rect) { TileData *tile_data; TriangulationData *triangulation; int triangles_allocated = 0; int chunk_size = 20; int i; rctf rect_float; if (this->m_movieClip == NULL) return NULL; if (!this->m_cachedTriangulation) { lockMutex(); if (this->m_cachedTriangulation == NULL) { this->m_cachedTriangulation = buildVoronoiTriangulation(); } unlockMutex(); } triangulation = this->m_cachedTriangulation; if (!triangulation) return NULL; BLI_rctf_init(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); for (i = 0; i < triangulation->triangles_total; i++) { bool ok = BLI_rctf_isect(&rect_float, &triangulation->triangles_AABB[i], NULL); if (ok) { tile_data->triangles_total++; if (tile_data->triangles_total > triangles_allocated) { if (!tile_data->triangles) { tile_data->triangles = (int *) MEM_mallocN(sizeof(int) * chunk_size, "keying screen tile triangles chunk"); } else { tile_data->triangles = (int *) MEM_reallocN(tile_data->triangles, sizeof(int) * (triangles_allocated + chunk_size)); } triangles_allocated += chunk_size; } tile_data->triangles[tile_data->triangles_total - 1] = i; } } return tile_data; }
void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) *toFill = (void *)newValue; return retVal; }
void MyQueue::enqueue(AsyncCallState* state) { state->nextInQueue = NULL; lockMutex(&queueMutex); if (tail == NULL) { head = state; } else { tail->nextInQueue = state; } tail = state; unlockMutex(&queueMutex); semPost(&queueSem); }
void *SingleThreadedOperation::initializeTileData(rcti *rect) { if (this->m_cachedInstance) return this->m_cachedInstance; lockMutex(); if (this->m_cachedInstance == NULL) { // this->m_cachedInstance = createMemoryBuffer(rect); } unlockMutex(); return this->m_cachedInstance; }
static void callMethod(Thread *self, Object *obj, Method *method) { JValue unused; /* Keep track of the method we're about to call and * the current time so that other threads can detect * when this thread wedges and provide useful information. */ gDvm.gcHeap->heapWorkerInterpStartTime = dvmGetRelativeTimeUsec(); gDvm.gcHeap->heapWorkerInterpCpuStartTime = dvmGetThreadCpuTimeUsec(); gDvm.gcHeap->heapWorkerCurrentMethod = method; gDvm.gcHeap->heapWorkerCurrentObject = obj; /* Call the method. * * Don't hold the lock when executing interpreted * code. It may suspend, and the GC needs to grab * heapWorkerLock. */ dvmUnlockMutex(&gDvm.heapWorkerLock); if (false) { /* Log entry/exit; this will likely flood the log enough to * cause "logcat" to drop entries. */ char tmpTag[16]; sprintf(tmpTag, "HW%d", self->systemTid); LOG(LOG_DEBUG, tmpTag, "Call %s\n", method->clazz->descriptor); dvmCallMethod(self, method, obj, &unused); LOG(LOG_DEBUG, tmpTag, " done\n"); } else { dvmCallMethod(self, method, obj, &unused); } /* * Reacquire the heap worker lock in a suspend-friendly way. */ lockMutex(&gDvm.heapWorkerLock); gDvm.gcHeap->heapWorkerCurrentObject = NULL; gDvm.gcHeap->heapWorkerCurrentMethod = NULL; gDvm.gcHeap->heapWorkerInterpStartTime = 0LL; /* Exceptions thrown during these calls interrupt * the method, but are otherwise ignored. */ if (dvmCheckException(self)) { #if DVM_SHOW_EXCEPTION >= 1 LOGI("Uncaught exception thrown by finalizer (will be discarded):\n"); dvmLogExceptionStackTrace(); #endif dvmClearException(self); } }
int AsyncServiceClientState::nextRequestId() { int result; lockMutex(&pImpl->requestIdMutex); result = pImpl->_nextRequestId; if (pImpl->_nextRequestId == REQUEST_ID_LIMIT) { pImpl->_nextRequestId = FIRST_REQUEST_ID; } else { pImpl->_nextRequestId++; } unlockMutex(&pImpl->requestIdMutex); return result; }
void Core::removeThread(Threaded *thread) { if(threadedEventMutex){ lockMutex(threadedEventMutex); for(int i=0; i < threads.size(); i++) { if(threads[i] == thread) { threads.erase(threads.begin() + i); return; } } unlockMutex(threadedEventMutex); } }