Command* Parser::nextCommand() throw(ParserException, UnsafeInterruptException) { Debug("parser") << "nextCommand()" << std::endl; Command* cmd = NULL; if (!d_commandQueue.empty()) { cmd = d_commandQueue.front(); d_commandQueue.pop_front(); setDone(cmd == NULL); } else { try { cmd = d_input->parseCommand(); d_commandQueue.push_back(cmd); cmd = d_commandQueue.front(); d_commandQueue.pop_front(); setDone(cmd == NULL); } catch (ParserException& e) { setDone(); throw; } catch (exception& e) { setDone(); parseError(e.what()); } } Debug("parser") << "nextCommand() => " << cmd << std::endl; if (cmd != NULL && dynamic_cast<SetOptionCommand*>(cmd) == NULL && dynamic_cast<QuitCommand*>(cmd) == NULL) { // don't count set-option commands as to not get stuck in an infinite // loop of resourcing out const Options& options = d_exprManager->getOptions(); d_resourceManager->spendResource(options.getParseStep()); } return cmd; }
Command* Parser::nextCommand() throw(ParserException) { Debug("parser") << "nextCommand()" << std::endl; Command* cmd = NULL; if(!d_commandQueue.empty()) { cmd = d_commandQueue.front(); d_commandQueue.pop_front(); setDone(cmd == NULL); } else { try { cmd = d_input->parseCommand(); d_commandQueue.push_back(cmd); cmd = d_commandQueue.front(); d_commandQueue.pop_front(); setDone(cmd == NULL); } catch(ParserException& e) { setDone(); throw; } catch(exception& e) { setDone(); parseError(e.what()); } } Debug("parser") << "nextCommand() => " << cmd << std::endl; return cmd; }
int licensePage::setReady() { if (agreeCheckBox->isChecked()) { setDone(true); } else { setDone(false); } return 0; }
int configurationPage::confirmRootPassword() { QString icon; if(rootPasswordLineEdit->text() == rootPasswordConfLineEdit->text()) { icon = getApplicationFile("/Icons/right.png"); setDone(true); } else { icon = getApplicationFile("/Icons/wrong.png"); setDone(false); } rootPasswordConfLabel->setText("<img src=\""+icon+ "\" height=20 width=20 >"); return 0; }
Task * RmdupBamWorker::tick() { if (inputUrlPort->hasMessage()) { const QString url = takeUrl(); CHECK(!url.isEmpty(), NULL); const QString detectedFormat = FileAndDirectoryUtils::detectFormat(url); if(detectedFormat.isEmpty()){ coreLog.info(tr("Unknown file format: ") + url); return NULL; } if(detectedFormat == BaseDocumentFormats::BAM){ const QString outputDir = FileAndDirectoryUtils::createWorkingDir(url, getValue<int>(OUT_MODE_ID), getValue<QString>(CUSTOM_DIR_ID), context->workingDir()); BamRmdupSetting setting; setting.outDir = outputDir; setting.outName = getTargetName(url, outputDir); setting.inputUrl = url; setting.removeSingleEnd = getValue<bool>(REMOVE_SINGLE_END_ID); setting.treatReads = getValue<bool>(TREAT_READS_ID); SamtoolsRmdupTask *t = new SamtoolsRmdupTask(setting); t->addListeners(createLogListeners()); connect(new TaskSignalMapper(t), SIGNAL(si_taskFinished(Task*)), SLOT(sl_taskFinished(Task*))); return t; } } if (inputUrlPort->isEnded()) { setDone(); outputUrlPort->setEnded(); } return NULL; }
void GetUserTrackRequest::processPacket(PacketContainer* pack) { switch (m_state) { case INIT: mc2log << error << "GetUserTrackRequest: Got packet in INIT" << endl; break; case GET_USER_TRACK_PACKET : { GetUserTrackReplyPacket* p = static_cast<GetUserTrackReplyPacket*>(pack->getPacket()); if (p->getStatus() == StringTable::OK) { p->getUserTrackElements(m_resultElements); m_state = DONE; setDone(true); } else { m_state = ERROR; } } break; case DONE: mc2log << error << "GetUserTrackRequest: Got packet in DONE" << endl; break; case ERROR: mc2log << error << "GetUserTrackRequest: Got packet in ERROR" << endl; break; } delete pack; }
void AlarmSchedulerPrecise::processExpiredAlarms( boost::optional<AlarmScheduler::AlarmExpireHook> hook) { AlarmCount processed = 0; auto now = clockSource()->now(); std::vector<Promise<void>> toExpire; AlarmMapIt it; stdx::unique_lock<stdx::mutex> lk(_mutex); for (it = _alarms.begin(); it != _alarms.end();) { if (hook && !(*hook)(processed + 1)) { break; } if (it->first > now) { break; } processed++; toExpire.push_back(std::move(it->second.promise)); auto handle = it->second.handle.lock(); if (handle) { handle->setDone(); } it = _alarms.erase(it); } lk.unlock(); for (auto& promise : toExpire) { promise.emplaceValue(); } }
Task* PFMatrixBuildWorker::tick() { if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); if (inputMessage.isEmpty()) { output->transit(); return NULL; } mtype = PFMatrixWorkerFactory::FREQUENCY_MATRIX_MODEL_TYPE(); QVariantMap data = inputMessage.getData().toMap(); cfg.type = actor->getParameter(TYPE_ATTR)->getAttributeValue<bool>(context) ? PM_DINUCLEOTIDE : PM_MONONUCLEOTIDE; QVariantMap qm = inputMessage.getData().toMap(); SharedDbiDataHandler msaId = qm.value(BaseSlots::MULTIPLE_ALIGNMENT_SLOT().getId()).value<SharedDbiDataHandler>(); QScopedPointer<MAlignmentObject> msaObj(StorageUtils::getMsaObject(context->getDataStorage(), msaId)); SAFE_POINT(!msaObj.isNull(), "NULL MSA Object!", NULL); const MAlignment &msa = msaObj->getMAlignment(); Task* t = new PFMatrixBuildTask(cfg, msa); connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished())); return t; } else if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
Task * MergeFastqWorker::tick() { while (inputUrlPort->hasMessage()) { const QString url = takeUrl(); CHECK(!url.isEmpty(), NULL); inputUrls.append(url); } if (!inputUrlPort->isEnded()) { return NULL; } if(!inputUrls.isEmpty()){ const QString outputDir = FileAndDirectoryUtils::createWorkingDir(inputUrls.first(), getValue<int>(OUT_MODE_ID), getValue<QString>(CUSTOM_DIR_ID), context->workingDir()); BaseNGSSetting setting; setting.outDir = outputDir; setting.outName = getTargetName(inputUrls.first(), outputDir); setting.inputUrl = inputUrls.first(); setting.customParameters = getCustomParameters(); setting.listeners = createLogListeners(); Task *t = getTask(setting); connect(new TaskSignalMapper(t), SIGNAL(si_taskFinished(Task*)), SLOT(sl_taskFinished(Task*))); inputUrls.clear();; return t; } if (inputUrlPort->isEnded()) { setDone(); outputUrlPort->setEnded(); } return NULL; }
Task * CufflinksWorker::tick() { if (false == settingsAreCorrect) { return NULL; } if (input->hasMessage()) { Message inputMessage = getMessageAndSetupScriptValues(input); SAFE_POINT(!inputMessage.isEmpty(), "Internal error: message can't be NULL!", NULL); QVariantMap data = inputMessage.getData().toMap(); if (settings.fromFile) { settings.url = data[BaseSlots::URL_SLOT().getId()].toString(); } else { settings.assemblyId = data[BaseSlots::ASSEMBLY_SLOT().getId()].value<SharedDbiDataHandler>(); } // Create the task CufflinksSupportTask* cufflinksSupportTask = new CufflinksSupportTask(settings); cufflinksSupportTask->addListeners(createLogListeners()); connect(cufflinksSupportTask, SIGNAL(si_stateChanged()), SLOT(sl_cufflinksTaskFinished())); return cufflinksSupportTask; } else if (input->isEnded()) { setDone(); output->setEnded(); } return NULL; }
void doJob() { test("Nothing"); postBlinds.insert(HDValue(Hash("ARC1"), "")); test("Single blind install"); postBlinds.insert(HDValue(Hash("ARC2"), "a")); postBlinds.insert(HDValue(Hash("ARC3"), "b/")); post["blah"] = Hash("blah"); test("Multi-blind install with paths"); postBlinds.insert(HDValue(Hash("ARC1"), "")); pre["blah"] = Hash("blah"); test("Single install, with upgrade info present"); preBlinds.insert(HDValue(Hash("ARC1"), "")); preBlinds.insert(HDValue(Hash("ARC2"), "a")); postBlinds.insert(HDValue(Hash("ARC3"), "b/")); postBlinds.insert(HDValue(Hash("ARC4"), "")); test("Pre and post blinds"); preBlinds.insert(HDValue(Hash("ARC1"), "")); preBlinds.insert(HDValue(Hash("ARC2"), "a")); test("Just pre blinds"); assert(!checkStatus()); setDone(); }
Task * SortBamWorker::tick() { if (inputUrlPort->hasMessage()) { const QString url = takeUrl(); CHECK(!url.isEmpty(), NULL); const QString detectedFormat = FileAndDirectoryUtils::detectFormat(url); if(detectedFormat.isEmpty()){ coreLog.info(tr("Unknown file format: ") + url); return NULL; } if(detectedFormat == BaseDocumentFormats::BAM){ const QString outputDir = FileAndDirectoryUtils::createWorkingDir(url, getValue<int>(OUT_MODE_ID), getValue<QString>(CUSTOM_DIR_ID), context->workingDir()); BamSortSetting setting; setting.outDir = outputDir; setting.outName = getTargetName(url, outputDir); setting.inputUrl = url; setting.index = getValue<bool>(INDEX_ID); Task *t = new SamtoolsSortTask(setting); connect(new TaskSignalMapper(t), SIGNAL(si_taskFinished(Task*)), SLOT(sl_taskFinished(Task*))); return t; } } if (inputUrlPort->isEnded()) { setDone(); outputUrlPort->setEnded(); } return NULL; }
void BrowseModelPrivate::onCallReady() { auto call = qobject_cast<ServiceProxyCall *>(sender()); if (call == 0) { return; } if (call->cancelled()) { return; } call->finalize(QStringList() << QLatin1String("Result") << QLatin1String("NumberReturned") << QLatin1String("TotalMatches")); setBusy(false); if (call->hasError()) { Q_EMIT error(call->errorCode(), call->errorMessage()); return; } unsigned int numberReturned = call->get(QLatin1String("NumberReturned")).toUInt(); if (numberReturned == 0) { setDone(true); return; } auto objects = DIDLLiteParser().parse(call->get(QLatin1String("Result")).toString()); beginInsertRows(QModelIndex(), m_data.count(), m_data.count() + numberReturned - 1); m_data << objects; endInsertRows(); m_currentOffset += numberReturned; unsigned int totalMatches = call->get(QLatin1String("TotalMatches")).toUInt(); if (totalMatches > 0 && m_currentOffset < totalMatches) { m_call->setArg(QLatin1String("StartingIndex"), m_currentOffset); m_call->run(); } else { setDone(true); } }
/** Executes the request now, i.e. in the main thread and without involving * the manager thread.. This calles prepareOperation, operation, and * afterOperation. */ void Request::executeNow() { assert(isPreparing()); setBusy(); execute(); callback(); setDone(); } // executeNow
int languagesPage::initAll() { pageBase::initAll(); initLanguages(); connect(okPushButton, SIGNAL(clicked()), this, SLOT(applyLanguage())); setDone(true); return 0; }
Expr Parser::nextExpression() throw(ParserException) { Debug("parser") << "nextExpression()" << std::endl; Expr result; if(!done()) { try { result = d_input->parseExpr(); setDone(result.isNull()); } catch(ParserException& e) { setDone(); throw; } catch(exception& e) { setDone(); parseError(e.what()); } } Debug("parser") << "nextExpression() => " << result << std::endl; return result; }
MainMenu::MainMenu( World * worldObject ) { cout << "Main Menu instansiated . . .\n\n"; setNextState (Screen_GAME); setDone(true); //object setup this->worldObject = worldObject; // world object }
virtual MoveInfo getMove(Creature* c) override { if (!c->hasSkill(Skill::get(SkillId::CONSTRUCTION))) return NoMove; Vec2 dir = getPosition() - c->getPosition(); if (dir.length8() == 1) { if (c->canConstruct(dir, type)) return {1.0, [this, c, dir] { c->construct(dir, type); if (!c->canConstruct(dir, type)) { setDone(); getCollective()->onConstructed(getPosition(), type); } }}; else { setDone(); return NoMove; } } else return getMoveToPosition(c); }
Expr Parser::nextExpression() throw(ParserException, UnsafeInterruptException) { Debug("parser") << "nextExpression()" << std::endl; const Options& options = d_exprManager->getOptions(); d_resourceManager->spendResource(options.getParseStep()); Expr result; if (!done()) { try { result = d_input->parseExpr(); setDone(result.isNull()); } catch (ParserException& e) { setDone(); throw; } catch (exception& e) { setDone(); parseError(e.what()); } } Debug("parser") << "nextExpression() => " << result << std::endl; return result; }
void ExpandRouteRequest::processPacket( PacketContainer* cont ) { m_expander->packetReceived( cont ); if (m_expander->getDone()) { // We're done, create answer. Answer can be null, // then something went wrong. m_answer = m_expander->createAnswer(); setDone( true ); } delete cont; }
void BrowseModelPrivate::refresh() { beginResetModel(); setDone(false); setBusy(true); m_currentOffset = 0; m_data.clear(); qDebug () << "Starting to browse" << m_call->arg(QLatin1String("ObjectID")); m_call->setArg(QLatin1String("StartingIndex"), m_currentOffset); m_call->run(); endResetModel(); }
void ConservationPlotWorker::sl_taskFinished() { ConservationPlotTask *t = dynamic_cast<ConservationPlotTask*>(sender()); if (!t->isFinished() || t->hasError() || t->isCanceled()) { return; } context->getMonitor()->addOutputFile(t->getSettings().outFile, getActor()->getId(), true); if (inChannel->isEnded() && !inChannel->hasMessage()) { setDone(); } }
int KernelRenderThread::cancel() { if (isRunning()) { setDone(true); while (isRunning()) { OpenThreads::Thread::YieldCurrentThread(); } } return 0; }
Task* SiteconReader::tick() { if (urls.isEmpty() && tasks.isEmpty()) { setDone(); output->setEnded(); } else { Task* t = new SiteconReadTask(urls.takeFirst()); connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished())); tasks.append(t); return t; } return NULL; }
virtual MoveInfo getMove(Creature* c) override { CHECK(!pickedUp); if (!itemsExist(c->getLevel()->getSquare(position))) { callback->onCantPickItem(items); setDone(); return NoMove; } if (c->getPosition() == position) { vector<Item*> hereItems; for (Item* it : c->getPickUpOptions()) if (items.contains(it)) { hereItems.push_back(it); items.erase(it); } callback->onCantPickItem(items); if (hereItems.empty()) { setDone(); return NoMove; } items = hereItems; if (auto action = c->pickUp(hereItems)) return {1.0, action.append([=] { pickedUp = true; onPickedUp(); callback->onPickedUp(position, hereItems); })}; else { callback->onCantPickItem(items); setDone(); return NoMove; } } if (auto action = c->moveTowards(position, true)) return action; else if (--tries == 0) { callback->onCantPickItem(items); setDone(); } return NoMove; }
virtual MoveInfo getMove(Creature* c) override { CHECK(!pickedUp); if (c->getPosition() == getPosition()) { vector<Item*> hereItems; for (Item* it : c->getPickUpOptions()) if (items.contains(it)) { hereItems.push_back(it); items.erase(it); } getCollective()->onCantPickItem(items); if (hereItems.empty()) { setDone(); return NoMove; } items = hereItems; if (c->canPickUp(hereItems)) return {1.0, [=] { for (auto elem : Item::stackItems(hereItems)) c->globalMessage(c->getTheName() + " picks up " + elem.first, ""); c->pickUp(hereItems); pickedUp = true; onPickedUp(); getCollective()->onPickedUp(getPosition(), hereItems); }}; else { getCollective()->onCantPickItem(items); setDone(); return NoMove; } } if (MoveInfo move = getMoveToPosition(c, true)) return move; else if (--tries == 0) { getCollective()->onCantPickItem(items); setDone(); } return NoMove; }
void FindPrimerPairsWorker::sl_onTaskFinished(Task* t) { QString reportFileUrl = getValue<QString>(FindPrimerPairsWorkerFactory::OUT_FILE); FindPrimersTask* findTask = qobject_cast<FindPrimersTask*>(t); if(!findTask->hasError() && !findTask->isCanceled()) { if(!findTask->getReport().isEmpty()) { context->getMonitor()->addOutputFile(reportFileUrl, getActor()->getId(), true); } else { context->getMonitor()->addError(tr("No correct primers pairs found"), getActor()->getId(), WorkflowNotification::U2_WARNING); } } setDone(); }
void StartStage_AutoPatch::beginDownload() { if (!m_pkCurrentDownloadTask && m_kDownloadList.size()) { m_pkCurrentDownloadTask = m_kDownloadList.at(0); m_kDownloadList.erase(m_kDownloadList.begin()); m_pkCurrentDownloadTask->Download(); } else if (0 == m_kDownloadList.size()) { setDone(); m_pkStageUI->showDone(); } }
void doJob() { test("Empty"); a("file1", Hash("FILE1")); a("file2", Hash("FILE2")); d("file3", Hash("FILE3")); d("file4", Hash("FILE4")); test("Non-matching entries"); a("file1", Hash("FILE1")); a("file2", Hash("FILE2")); d("file3", Hash("FILE2")); d("file4", Hash("FILE4")); test("One matching entry"); d("file1", Hash("FILE1")); d("file2", Hash("FILE1")); d("file3", Hash("FILE2")); d("file4", Hash("FILE2")); a("file5", Hash("FILE1")); a("file6", Hash("FILE2")); a("file7", Hash("FILE1")); test("Multiple options"); d("file1", Hash("FILE1")); d("file2", Hash("FILE2")); d("file3", Hash("FILE3")); d("file4", Hash("FILE4")); a("file5", Hash("FILE3")); a("file6", Hash("FILE1")); a("file7", Hash("FILE4")); a("file8", Hash("FILE2")); test("All entries matching"); // This would give undefined results in the real world d("file1", Hash("FILE1")); d("file2", Hash("FILE2")); d("file3", Hash("FILE3")); d("file4", Hash("FILE4")); a("file1", Hash("FILE3")); a("file2", Hash("FILE1")); a("file3", Hash("FILE4")); a("file4", Hash("FILE2")); test("Pandemonium!"); setDone(); }
Task * GetFileListWorker::tick() { if (files->hasNext()) { QVariantMap m; QString url = files->getNextFile(); QString datasetName = files->getLastDatasetName(); m[BaseSlots::URL_SLOT().getId()] = url; m[BaseSlots::DATASET_SLOT().getId()] = datasetName; MessageMetadata metadata(url, datasetName); context->getMetadataStorage().put(metadata); outChannel->put(Message(outChannel->getBusType(), m, metadata.getId())); } else { setDone(); outChannel->setEnded(); } return NULL; }