diff --git a/include/Data/IDataProvider.h b/include/Data/IDataProvider.h index ba4e869..5a1aae3 100644 --- a/include/Data/IDataProvider.h +++ b/include/Data/IDataProvider.h @@ -27,6 +27,7 @@ DEPRECATE( * * A data provider is an entity that generates data and returns it according to various parameters * (time interval, product to retrieve the data, etc.) + * Since its client mihgt use it from different threads it has to be either stateless and/or thread safe * * @sa IDataSeries */ @@ -37,71 +38,13 @@ public: virtual ~IDataProvider() noexcept = default; virtual std::shared_ptr clone() const = 0; - DEPRECATE( - /** - * @brief requestDataLoading provide datas for the data identified by acqIdentifier and - * parameters - */ - virtual void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) - = 0; - ) - // Synchronous call -> asyncGetData may be written for asynchronous get - virtual IDataSeries* getData(const DataProviderParameters ¶meters) - { - Q_UNUSED(parameters); - return nullptr; - } - - - DEPRECATE( - /** - * @brief requestDataAborting stop data loading of the data identified by acqIdentifier - */ - virtual void requestDataAborting(QUuid acqIdentifier) = 0; - ) - - virtual void abort(QUuid requestID){Q_UNUSED(requestID);} + virtual IDataSeries* getData(const DataProviderParameters ¶meters) = 0; signals: - DEPRECATE( - /** - * @brief dataProvided send dataSeries under dateTime and that corresponds of the data - * identified by acqIdentifier - */ - void dataProvided(QUuid acqIdentifier, std::shared_ptr dateSeriesAcquired, - const DateTimeRange &dataRangeAcquired); - ) - - void finished(QUuid requestID, std::shared_ptr dataSerie, - const DateTimeRange &range); - - DEPRECATE( - /** - * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier - */ - void dataProvidedProgress(QUuid acqIdentifier, double progress); - ) void progress(QUuid requestID, double progress); - DEPRECATE( - /** - * @brief dataProvidedFailed notify that data acquisition has failed - */ - void dataProvidedFailed(QUuid acqIdentifier); - ) - - void failed(QUuid requestID); - - /** - * @brief requestConstructed send a request for the data identified by acqIdentifier - * @callback is the methode call by the reply of the request when it is finished. - */ - DEPRECATE( - void requestConstructed(std::shared_ptr request, QUuid acqIdentifier, - std::function callback); - ) }; // Required for using shared_ptr in signals/slots diff --git a/include/Variable/private/VCTransaction.h b/include/Variable/private/VCTransaction.h index 1c88700..ab38dce 100644 --- a/include/Variable/private/VCTransaction.h +++ b/include/Variable/private/VCTransaction.h @@ -57,7 +57,9 @@ public: std::vector data; for(auto range:_ranges) { - data.push_back(_provider->getData(DataProviderParameters{{range}, _variable->metadata()})); + auto ds = _provider->getData(DataProviderParameters{{range}, _variable->metadata()}); + if(ds) + data.push_back(ds); } _variable->updateData(data, _range, _cacheRange, true); emit transactionComplete(); diff --git a/src/Network/Downloader.cpp b/src/Network/Downloader.cpp index 29a9f1a..cafd2b9 100644 --- a/src/Network/Downloader.cpp +++ b/src/Network/Downloader.cpp @@ -10,6 +10,7 @@ #include #include #include +#include class Downloader::p_Downloader { @@ -56,7 +57,10 @@ public: QNetworkRequest request = buildRequest(url, user, passwd); QNetworkReply *reply = manager.get(request); while (!reply->isFinished()) + { QCoreApplication::processEvents(); + QThread::usleep(10000); + } QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); Response resp = Response(reply->readAll(), status_code.toInt()); delete reply; diff --git a/src/Variable/VariableController2.cpp b/src/Variable/VariableController2.cpp index 53b6c76..6d4b3a3 100644 --- a/src/Variable/VariableController2.cpp +++ b/src/Variable/VariableController2.cpp @@ -117,7 +117,7 @@ class VariableController2::VariableController2Private QMap> _synchronizationGroups; QReadWriteLock _lock{QReadWriteLock::Recursive}; }_maps; - QThreadPool _ThreadPool; + QThreadPool* _ThreadPool; VCTransactionsQueues _transactions; std::unique_ptr _cacheStrategy; @@ -153,7 +153,7 @@ class VariableController2::VariableController2Private this->_transactionComplete(groupID, transaction); } ); - _ThreadPool.start(exe); + _ThreadPool->start(exe); } } } @@ -229,7 +229,8 @@ public: :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)) { Q_UNUSED(parent); - this->_ThreadPool.setMaxThreadCount(32); + this->_ThreadPool = new QThreadPool(); + this->_ThreadPool->setMaxThreadCount(32); } /* @@ -239,10 +240,7 @@ public: */ ~VariableController2Private() { - while (this->_ThreadPool.activeThreadCount()) - { - this->_ThreadPool.waitForDone(100); - } + delete this->_ThreadPool; } std::shared_ptr createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr provider) @@ -330,7 +328,7 @@ std::shared_ptr VariableController2::createVariable(const QString &nam auto var = impl->createVariable(name, metadata, provider); emit variableAdded(var); if(!DateTimeRangeHelper::hasnan(range)) - impl->changeRange(var,range); + impl->asyncChangeRange(var,range); else SCIQLOP_ERROR(VariableController2, "Creating a variable with default constructed DateTimeRange is an error"); return var; diff --git a/tests/TestUtils/TestProviders.h b/tests/TestUtils/TestProviders.h index a425beb..8e6ad02 100644 --- a/tests/TestUtils/TestProviders.h +++ b/tests/TestUtils/TestProviders.h @@ -42,19 +42,6 @@ public: return serie; } - - - void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) override - { - Q_UNUSED(acqIdentifier) - Q_UNUSED(parameters) - } - - void requestDataAborting(QUuid acqIdentifier) override - { - Q_UNUSED(acqIdentifier) - } - };