void MediaDownload::startRequest(unsigned position, unsigned size) { Q_ASSERT(m_url.isValid()); if (m_task) { m_task->abortLater(); m_task->deleteLater(); } m_task = new MediaDownloadTask; m_task->moveToThread(m_thread); connect(m_task, SIGNAL(requestReady(uint)), SLOT(requestReady(uint)), Qt::DirectConnection); connect(m_task, SIGNAL(dataRead(QByteArray,uint)), SLOT(incomingData(QByteArray,uint)), Qt::DirectConnection); connect(m_task, SIGNAL(finished()), SLOT(taskFinished()), Qt::DirectConnection); connect(m_task, SIGNAL(error(QString)), SLOT(taskError(QString)), Qt::DirectConnection); /* If size will reach the end of what we believe the file size to be, make it infinite instead, * to ease behavior with still active files */ if (position + size >= m_fileSize) size = 0; bool ok = m_task->metaObject()->invokeMethod(m_task, "start", Q_ARG(QUrl, m_url), Q_ARG(QList<QNetworkCookie>, m_cookies), Q_ARG(unsigned, position), Q_ARG(unsigned, size)); Q_ASSERT(ok); Q_UNUSED(ok); }
void TaskManager::run() { qDebug() << "taskmanager is running"; if (!m_passward.isEmpty()) { m_pProc = new QProcess(); /* task No1 : run updatedb */ emit taskFinished(TASKID_UPDATE_LOCATEDB, sudoRunProcess("updatedb")); /* task No2 : run everything-updatedb */ emit taskFinished(TASKID_UPDATE_SEARCHDB, sudoRunProcess("./everything-updatedb")); } exit(); }
/** * \brief Call this when you need to retrieve fresh vCard from server (and store it in cache afterwards) */ JT_VCard* VCardFactory::getVCard(const Jid &jid, Task *rootTask, const QObject *obj, const char *slot, bool cacheVCard) { JT_VCard *task = new JT_VCard( rootTask ); if ( cacheVCard ) task->connect(task, SIGNAL(finished()), this, SLOT(taskFinished())); task->connect(task, SIGNAL(finished()), obj, slot); task->get(Jid(jid.full())); task->go(true); return task; }
void GenGraphForm::runTask() { QStringList argv = tasks.front(); tasks.pop_front(); exportButton->setText("&Kill"); QString cmd = argv.join(QString(" ")); std::cout << "STARTING TASK " << (const char*)cmd << std::endl; #ifdef SOFA_QT4 QProcess* p = new QProcess(this); QString program = argv.front(); argv.pop_front(); p->setReadChannelMode(QProcess::ForwardedChannels); connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(taskFinished())); p->start(program, argv); #else QProcess* p = new QProcess(argv, this); p->setCommunication(0); connect(p,SIGNAL(processExited()),this,SLOT(taskFinished())); p->start(); #endif currentTask = p; }
void GenericWatcher::run() { for (;; ) { { QMutexLocker quitLocker(&_imp->mustQuitMutex); if (_imp->mustQuit) { _imp->mustQuit = false; _imp->mustQuitCond.wakeAll(); return; } } int taskID = -1; boost::shared_ptr<GenericWatcherCallerArgs> inArgs; { QMutexLocker k(&_imp->tasksMutex); if ( !_imp->tasks.empty() ) { const GenericWatcherPrivate::Task& t = _imp->tasks.front(); taskID = t.id; inArgs = t.args; _imp->tasks.pop_front(); } } if (taskID != -1) { handleBlockingTask(taskID); Q_EMIT taskFinished(taskID, inArgs); } { QMutexLocker l(&_imp->startRequestsMutex); while (_imp->startRequests <= 0) { _imp->startRequestsCond.wait(&_imp->startRequestsMutex); } ///We got the request, reset it back to 0 _imp->startRequests = 0; } } // for(;;) }
/** call the TopDown Operator of the SNode */ void INode::execTopDown() { #ifdef DEBUGMSG qDebug("#* INode::execTopDown(%s)(%p): Start\n", (const char *) name(),this); #endif if (analysis()->error()) { status(TD_ABORTED); return; } execState(TD); CHECK_PTR(this->sNode()); if (sNode_->holistic()) sNode_->execTopDownOp(this); //start TD else if (!sNode_->attributeBool("td_multiclass")) taskFinished(0,0); else { parent()->decrementCount(); // status(TRASH); parent()->childUnlink(this); //!remove this temporary INode delete this; } }
/** * @brief Call zp_plTaskBase::popTask to fetch new tasks. * * @fn zp_plWorkingThread::FetchNewTask * @param obj the zp_plWorkingThread object recieved by signal-slot system. * this method will omit zp_plWorkingThread objs except for it self. */ void zp_plWorkingThread::FetchNewTask(zp_plWorkingThread * obj) { if (obj != this) return; if (m_bRuning) { bool bValid = false; zp_plTaskBase * ptr = this->m_pipeline->popTask(&bValid); if (bValid==true && ptr!=NULL) { m_bBusy = true; if (ptr->LockRun()==true) { int res = ptr->run(); ptr->delRef(); if (res!=0 ) this->m_pipeline->pushTask(ptr,false); ptr->UnlockRun(); } else { ptr->delRef(); this->m_pipeline->pushTask(ptr,false); } m_bBusy = false; } emit taskFinished(this); } }
void CNodeGateTask::run() { // Report that we are starting, if appropriate. CProgressInfo progress; progress.setSrc(CProgressInfo::ESource::node); progress.setState(CProgressInfo::EState::processing); progress.setName(m_node.getConfig().getName()); if(CSettings::progress()) { progress.setMsg(CProgressInfo::EMsg::start); progress.printProgress(); } // Enable the usage of the commit functions only while the data function // ... is called. m_node.m_allow_commit = true; // Perform the actual processing of the data. bool processed = m_node.data(m_gate_name, m_data); // Dissalow the commit functions outside of the nodes' data function. m_node.m_allow_commit = false; // If a Node did not process the data it was sent, try to process it // ... in a generic way if we know how to treat the data. if(!processed) { m_node.genericData(m_gate_name, m_data); } // Report that we are finished processing, if apropriate. if(CSettings::progress()) { progress.setMsg(CProgressInfo::EMsg::stop); progress.printProgress(); } // Tell whoever is interested that the task has been finished. emit taskFinished(); }
/* * 接受isoftappdaemon finished 信号 * 1.更新所有包列表中对应包的状态 * 2.给每个页面发送taskfinished信号 * 3.更新taskqueue队列: * a、删除当前任务 * b、开始新任务 */ void JadedBus::getFinished(const QString &pkgName,qlonglong status) { if (status != STATUS_REMOVED && status != STATUS_UPDATED && status != STATUS_INSTALLED && status != STATUS_INSTALL && status != STATUS_UPGRADED && status != STATUS_INSTALL_ERROR) { return; } if(pkgName.isEmpty()) { return; } int i =0; for (i = 0; i < AllPkgList.size(); ++i) { if (AllPkgList.at(i).pkgName == pkgName) { if (status == STATUS_INSTALLED) { if (AllPkgList[i].status != 1) { AllPkgList[i].status = 1; QDateTime local(QDateTime::currentDateTime()); AllPkgList[i].datetime = local.toString("yyyy-MM-dd hh:mm:ss"); QString desktopName = m_isoftapp->GetDesktopName(pkgName).value(); if (!desktopName.isEmpty()) desktopName = desktopName.left(desktopName.size() - 8); KService::Ptr service = KService::serviceByDesktopName(desktopName); if (!service) { service = KService::serviceByDesktopName(pkgName); } if (service) { if (!service->exec().isEmpty() && !service->noDisplay()) { QFile::link(service->entryPath(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/" + service->name() + ".desktop"); } } } } else if (status == STATUS_REMOVED) { if (AllPkgList[i].status != 2) { AllPkgList[i].status = 2; QDateTime local(QDateTime::currentDateTime()); AllPkgList[i].datetime = local.toString("yyyy-MM-dd hh:mm:ss"); } } else if ( status == STATUS_INSTALL_ERROR) { if (AllPkgList[i].status != 2) { AllPkgList[i].status = 2; } QString details ="insatallfailed"; m_errored(pkgName,details); } getMyPkgNumber(); break; } } taskFinished(pkgName); for (i = 0; i < m_taskQueue.size(); i++) { if (m_taskQueue[i].status == "doing" && pkgName == m_taskQueue[i].name) { if (m_taskQueue[i].action == "update") { int t = (int)time(NULL); m_updateInfo.replace(pkgName,QString::number(t, 10)); //getUpdate() ; } printf("trace:%s,%d,name[%s],index[%d][%s] task is finished.\n",__FUNCTION__,__LINE__, qPrintable(m_taskQueue[i].name),i,qPrintable(m_taskQueue[i].action)); m_taskQueue[i].status = "done"; g_doingPkgName = ""; m_taskQueue.removeFirst(); m_runTask(); return; } } return; }
void SCsParseExtractIdftAsynchTask::finished() { emit taskFinished(); }
SCsParseExtractIdftAsynchTask::SCsParseExtractIdftAsynchTask(const QString &text, QObject *parent) : QObject(parent) , mText(text) { connect(&mWatcher,SIGNAL(finished()),this,SIGNAL(taskFinished())); }
void SCsParseExceptionsAsynchTask::finished() { emit taskFinished(); }
void AudioFileCopyConvert::process_task(CopyTask task) { emit taskStarted(task.readsource->get_name()); uint buffersize = 16384; DecodeBuffer decodebuffer; task.spec->startLocation = TimeRef(); task.spec->endLocation = task.readsource->get_length(); task.spec->totalTime = task.spec->endLocation; task.spec->pos = TimeRef(); task.spec->isRecording = false; task.spec->exportdir = task.dir; task.spec->writerType = "sndfile"; task.spec->extraFormat["filetype"] = "wav"; task.spec->data_width = 1; // 1 means float task.spec->channels = task.readsource->get_channel_count(); task.spec->sample_rate = task.readsource->get_rate(); task.spec->blocksize = buffersize; task.spec->name = task.outFileName; task.spec->dataF = new audio_sample_t[buffersize * 2]; WriteSource* writesource = new WriteSource(task.spec); bool failedToPrepareWritesource = false; int oldprogress = 0; if (writesource->prepare_export() == -1) { failedToPrepareWritesource = true; goto out; } // Enable on the fly generation of peak data to speedup conversion // (no need to re-read all the audio files to generate peaks) writesource->set_process_peaks(true); do { // if the user asked to stop processing, jump out of this // loop, and cleanup any resources in use. if (m_stopProcessing) { goto out; } nframes_t diff = (task.spec->endLocation - task.spec->pos).to_frame(task.readsource->get_rate()); nframes_t this_nframes = std::min(diff, buffersize); nframes_t nframes = this_nframes; memset (task.spec->dataF, 0, sizeof (task.spec->dataF[0]) * nframes * task.spec->channels); task.readsource->file_read(&decodebuffer, task.spec->pos, nframes); for (uint x = 0; x < nframes; ++x) { for (int y = 0; y < task.spec->channels; ++y) { task.spec->dataF[y + x*task.spec->channels] = decodebuffer.destination[y][x]; } } // due the fact peak generating does _not_ happen in writesource->process // but in a function used by DiskIO, we have to hack the peak processing // in here. for (int y = 0; y < task.spec->channels; ++y) { writesource->get_peak()->process(y, decodebuffer.destination[y], nframes); } // Process the data, and write to disk writesource->process(buffersize); task.spec->pos.add_frames(nframes, task.readsource->get_rate()); int currentprogress = int(double(task.spec->pos.universal_frame()) / double(task.spec->totalTime.universal_frame()) * 100); if (currentprogress > oldprogress) { oldprogress = currentprogress; emit progress(currentprogress); } } while (task.spec->pos != task.spec->totalTime); out: if (!failedToPrepareWritesource) { writesource->finish_export(); } delete writesource; delete [] task.spec->dataF; resources_manager()->remove_source(task.readsource); // The user asked to stop processing, exit the event loop // and signal we're done. if (m_stopProcessing) { exit(0); wait(1000); m_tasks.clear(); emit processingStopped(); return; } emit taskFinished(task.dir + "/" + task.outFileName + ".wav", task.tracknumber, task.trackname); }