void Worker::commandReceived(const QByteArray command) { if (m_currentState == StoppedState) { return; } if (command == "ok") { m_waitingCount--; emit currentLineChanged(m_currentLine - m_waitingCount + 1); if (m_waitingCount < m_bufferSize) { if ((m_currentLine < m_commandList.size()) && (m_currentState == RunningState)) // a new command needs to be sent { sendLine(); } } if ((m_waitingCount == 0) && (m_currentLine == m_commandList.size())) // we have finished { stopQueue(); m_currentState = StoppedState; emit currentStateChanged(m_currentState); emit finished(); } } }
void Worker::stop() { stopQueue(); m_currentState = StoppedState; emit currentStateChanged(m_currentState); }
void ThreadQueue::run(void) { data_t *prev; started = true; for(;;) { Semaphore::wait(); if(!started) sleep((timeout_t)~0); startQueue(); while(first) { runQueue(first->data); enterMutex(); prev = first; first = first->next; delete[] prev; if(!first) last = NULL; leaveMutex(); if(first) Semaphore::wait(); // demark semaphore } stopQueue(); } }
Controller::~Controller() { // stop background task queue thread stopQueue(); window->deleteLater(); delete subs; }
/** * \brief Slot to handle toolbar actions * * This is just a dispatcher method that calls the appropriate acction * handler slot. */ void TaskMainWindow::handleToolbarAction(QAction *action) { debug(LOG_DEBUG, DEBUG_LOG, 0, "toolbar action called"); if (action == ui->actionStartQueue) { startQueue(); return; } if (action == ui->actionStopQueue) { stopQueue(); return; } if (action == ui->actionDelete) { deleteSelected(); return; } if (action == ui->actionDownload) { downloadSelected(); return; } }
SipperProxyQueue::~SipperProxyQueue() { stopQueue(); int oldstate; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); pthread_mutex_lock(&tEventQueueMutex); //Queue should be destroyed after all its messages were given out. Since in //dequeue we are leaving out. I removed the check of queuecount != 0 here. while (sleepingFeeders || sleepingConsumers || waitingFeeders || waitingConsumers) { pthread_cond_wait(&waitingConsumerCond, &tEventQueueMutex); } if(iQueueCount != 0) { } t_EventQueueNodePtr currNode, nextNode; currNode = ptFreeList; for(unsigned int idx = 0; (idx < highWaterMark) && (currNode != NULL); idx++) { //NULL check is reqd as not all the nodes were captured back to freelist. //Some mem leaks because dequeue returns error even there are messages in //queue to process. nextNode = currNode->ptNextNode; delete currNode; currNode = nextNode; } pthread_mutex_unlock(&tEventQueueMutex); pthread_setcancelstate(oldstate, NULL); pthread_mutex_destroy(&tEventQueueMutex); pthread_cond_destroy(&waitingFeederCond); pthread_cond_destroy(&waitingConsumerCond); }
CoreBoundTaskQueue::~CoreBoundTaskQueue() { if (_thread != NULL) stopQueue(); }
CoreBoundPriorityQueue::~CoreBoundPriorityQueue() { if (_thread != nullptr) stopQueue(); }
CoreBoundQueue::~CoreBoundQueue() { if (_thread != nullptr) stopQueue(); }