##// END OF EJS Templates
Next var request parameter is now based on previous request instead of...
perrinel -
r807:0f020366c50a
parent child
Show More
@@ -117,6 +117,8 struct VariableController::VariableControllerPrivate {
117 void updateVariableRequest(QUuid varRequestId);
117 void updateVariableRequest(QUuid varRequestId);
118 void cancelVariableRequest(QUuid varRequestId);
118 void cancelVariableRequest(QUuid varRequestId);
119
119
120 SqpRange getLastRequestedRange(QUuid varId);
121
120 QMutex m_WorkingMutex;
122 QMutex m_WorkingMutex;
121 /// Variable model. The VariableController has the ownership
123 /// Variable model. The VariableController has the ownership
122 VariableModel *m_VariableModel;
124 VariableModel *m_VariableModel;
@@ -570,59 +572,70 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
570 const SqpRange &rangeRequested,
572 const SqpRange &rangeRequested,
571 QUuid varRequestId)
573 QUuid varRequestId)
572 {
574 {
573
574 // TODO: protect at
575 auto varRequest = VariableRequest{};
575 auto varRequest = VariableRequest{};
576 auto varId = m_VariableToIdentifierMap.at(var);
577
576
578 auto varStrategyRangesRequested
577 auto it = m_VariableToIdentifierMap.find(var);
579 = m_VariableCacheStrategy->computeRange(var->range(), rangeRequested);
578 if (it != m_VariableToIdentifierMap.cend()) {
580
579
581 auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second};
580 auto varId = it->second;
582 auto inCacheRangeList = QVector<SqpRange>{};
583 if (m_VarIdToVarRequestIdQueueMap.find(varId) == m_VarIdToVarRequestIdQueueMap.cend()) {
584 notInCacheRangeList = var->provideNotInCacheRangeList(varStrategyRangesRequested.second);
585 inCacheRangeList = var->provideInCacheRangeList(varStrategyRangesRequested.second);
586 }
587
581
588 if (!notInCacheRangeList.empty()) {
582 auto oldRange = getLastRequestedRange(varId);
589 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
590 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
591
583
592 // store VarRequest
584 // check for update oldRange to the last request range.
593 storeVariableRequest(varId, varRequestId, varRequest);
585 if (oldRange == INVALID_RANGE) {
586 oldRange = var->range();
587 }
588
589 auto varStrategyRangesRequested
590 = m_VariableCacheStrategy->computeRange(oldRange, rangeRequested);
594
591
595 auto varProvider = m_VariableToProviderMap.at(var);
592 auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second};
596 if (varProvider != nullptr) {
593 auto inCacheRangeList = QVector<SqpRange>{};
597 auto varRequestIdCanceled = m_VariableAcquisitionWorker->pushVariableRequest(
594 if (m_VarIdToVarRequestIdQueueMap.find(varId) == m_VarIdToVarRequestIdQueueMap.cend()) {
598 varRequestId, varId, varStrategyRangesRequested.first,
595 notInCacheRangeList
599 varStrategyRangesRequested.second,
596 = var->provideNotInCacheRangeList(varStrategyRangesRequested.second);
600 DataProviderParameters{std::move(notInCacheRangeList), var->metadata()},
597 inCacheRangeList = var->provideInCacheRangeList(varStrategyRangesRequested.second);
601 varProvider);
598 }
599
600 if (!notInCacheRangeList.empty()) {
601 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
602 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
603
604 // store VarRequest
605 storeVariableRequest(varId, varRequestId, varRequest);
606
607 auto varProvider = m_VariableToProviderMap.at(var);
608 if (varProvider != nullptr) {
609 auto varRequestIdCanceled = m_VariableAcquisitionWorker->pushVariableRequest(
610 varRequestId, varId, varStrategyRangesRequested.first,
611 varStrategyRangesRequested.second,
612 DataProviderParameters{std::move(notInCacheRangeList), var->metadata()},
613 varProvider);
614
615 if (!varRequestIdCanceled.isNull()) {
616 qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ")
617 << varRequestIdCanceled;
618 cancelVariableRequest(varRequestIdCanceled);
619 }
620 }
621 else {
622 qCCritical(LOG_VariableController())
623 << "Impossible to provide data with a null provider";
624 }
602
625
603 if (!varRequestIdCanceled.isNull()) {
626 if (!inCacheRangeList.empty()) {
604 qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ")
627 emit q->updateVarDisplaying(var, inCacheRangeList.first());
605 << varRequestIdCanceled;
606 cancelVariableRequest(varRequestIdCanceled);
607 }
628 }
608 }
629 }
609 else {
630 else {
610 qCCritical(LOG_VariableController())
631 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
611 << "Impossible to provide data with a null provider";
632 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
612 }
633 // store VarRequest
613
634 storeVariableRequest(varId, varRequestId, varRequest);
614 if (!inCacheRangeList.empty()) {
635 acceptVariableRequest(
615 emit q->updateVarDisplaying(var, inCacheRangeList.first());
636 varId, var->dataSeries()->subDataSeries(varStrategyRangesRequested.second));
616 }
637 }
617 }
638 }
618 else {
619 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
620 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
621 // store VarRequest
622 storeVariableRequest(varId, varRequestId, varRequest);
623 acceptVariableRequest(varId,
624 var->dataSeries()->subDataSeries(varStrategyRangesRequested.second));
625 }
626 }
639 }
627
640
628 std::shared_ptr<Variable>
641 std::shared_ptr<Variable>
@@ -838,3 +851,40 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid
838 }
851 }
839 }
852 }
840 }
853 }
854
855 SqpRange VariableController::VariableControllerPrivate::getLastRequestedRange(QUuid varId)
856 {
857 auto lastRangeRequested = SqpRange{INVALID_RANGE};
858 auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId);
859 if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) {
860 auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second;
861 auto varRequestId = varRequestIdQueue.back();
862 auto varRequestIdToVarIdVarRequestMapIt
863 = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId);
864 if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) {
865 auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second;
866 auto varIdToVarRequestMapIt = varIdToVarRequestMap.find(varId);
867 if (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) {
868 auto &varRequest = varIdToVarRequestMapIt->second;
869 lastRangeRequested = varRequest.m_RangeRequested;
870 }
871 else {
872 qCDebug(LOG_VariableController())
873 << tr("Impossible to getLastRequestedRange of a unknown variable id attached "
874 "to a variableRequestId")
875 << varRequestId << varId;
876 }
877 }
878 else {
879 qCCritical(LOG_VariableController())
880 << tr("Impossible to getLastRequestedRange of a unknown variableRequestId")
881 << varRequestId;
882 }
883 }
884 else {
885 qDebug(LOG_VariableController())
886 << tr("Impossible to getLastRequestedRange of a unknown variable id") << varId;
887 }
888
889 return lastRangeRequested;
890 }
General Comments 0
You need to be logged in to leave comments. Login now