void TaskQueue::addTasks(const TasksList &tasks) { { QMutexLocker lock(&_tasksToProcessMutex); _tasksToProcess.append(tasks); } wakeThread(); }
void JausTransportInterface::stopThread() { wakeThread(); pthread_join(this->pThread, NULL); this->queue.emptyQueue(); pthread_mutex_destroy(&this->threadMutex); pthread_cond_destroy(&this->threadConditional); }
void ExecutionTracker::launchThread(thrID target, SchedPointInfo * s) { log->scheduling(target, s); safe_assert(isEnabled(target)); if (cond_map[target] != NULL) { was_signalled_map[target] = false; waitWakeThread(target); } else { wakeThread(target); } }
TaskId TaskQueue::addTask(TaskPtr task) { { QMutexLocker lock(&_tasksToProcessMutex); _tasksToProcess.push_back(task); } wakeThread(); return task->id(); }
OMXCAM_ERROR OMXCAM_stopVideo (){ OMXCAM_trace ("Stopping video"); if (!running){ OMXCAM_error ("Video capture is not running"); return OMXCAM_ErrorVideo; } if (pthread_equal (pthread_self (), bgThread)){ //Background thread OMXCAM_trace ("Stopping from background thread"); //If stop() is called from inside the background thread (from the //bufferCallback), there's no need to use mutexes and join(), just set //running to false and the thread will die naturally running = 0; //This var is used to prevent calling mutex_lock() after mutex_destroy() safeRunning = 0; }else{ //Main thread OMXCAM_trace ("Stopping from main thread"); if (pthread_mutex_lock (&mutex)){ OMXCAM_error ("pthread_mutex_lock"); return OMXCAM_ErrorVideo; } running = 0; if (pthread_mutex_unlock (&mutex)){ OMXCAM_error ("pthread_mutex_unlock"); return OMXCAM_ErrorVideo; } if (pthread_join (bgThread, 0)){ OMXCAM_error ("pthread_join"); return OMXCAM_ErrorVideo; } } OMXCAM_ERROR error = deinitOMX (); if (sleeping){ if (wakeThread ()){ return error ? error : OMXCAM_ErrorWake; } }else if (locked){ if (unlockThread ()){ return error ? error : OMXCAM_ErrorUnlock; } } return OMXCAM_deinit (); }
void JausTransportInterface::queueJausMessage(JausMessage message) { if(this->running) { this->queue.push(message); wakeThread(); } else { jausMessageDestroy(message); } }
void VSThreadPool::startInternal(const PFrameContext &context) { //technically this could be done by walking up the context chain and add a new notification to the correct one //unfortunately this would probably be quite slow for deep scripts so just hope the cache catches it if (context->n < 0) vsFatal("Negative frame request by: %s", context->clip->getName().c_str()); // check to see if it's time to reevaluate cache sizes if (core->memory->isOverLimit()) { ticks = 0; notifyCaches(true); } // a normal tick for caches to adjust their sizes based on recent history if (!context->upstreamContext && ++ticks == 500) { ticks = 0; notifyCaches(false); } // add it immediately if the task is to return a completed frame or report an error since it never has an existing context if (context->returnedFrame || context->hasError()) { tasks.push_back(context); } else { if (context->upstreamContext) ++context->upstreamContext->numFrameRequests; NodeOutputKey p(context->clip, context->n, context->index); if (allContexts.count(p)) { PFrameContext &ctx = allContexts[p]; assert(context->clip == ctx->clip && context->n == ctx->n && context->index == ctx->index); if (ctx->returnedFrame) { // special case where the requested frame is encountered "by accident" context->returnedFrame = ctx->returnedFrame; tasks.push_back(context); } else { // add it to the list of contexts to notify when it's available context->notificationChain = ctx->notificationChain; ctx->notificationChain = context; ctx->reqOrder = std::min(ctx->reqOrder, context->reqOrder); } } else { // create a new context and append it to the tasks allContexts[p] = context; tasks.push_back(context); } } wakeThread(); }