Ref T149, utility functions for pending URLs

* Do not call read twice in info reader
* Threadsafe utility functions
This commit is contained in:
Klaus Basan
2017-09-17 23:35:50 +02:00
committed by Mathew Sutcliffe
parent 52caf795d1
commit 0cf308450e
5 changed files with 50 additions and 0 deletions

View File

@@ -83,6 +83,14 @@ namespace BlackCore
//! \remark needs to be done before started in different thread
void markAsUsedInUnitTest() { m_unitTest = true; }
//! Has pending URLs?
//! \threadsafe
bool hasPendingUrls() const;
//! Get the URL log list
//! \threadsafe
BlackMisc::Network::CUrlLogList getUrlLogList() const;
protected:
mutable QReadWriteLock m_lock { QReadWriteLock::Recursive }; //!< lock which can be used from the derived classes
@@ -106,9 +114,11 @@ namespace BlackCore
virtual void doWorkImpl() {}
//! Still enabled etc.?
//! \threadsafe under normal conditions
bool doWorkCheck() const;
//! Get request from network, and log with m_urlReadLog
//! \threadsafe read log access is thread safe
QNetworkReply *getFromNetworkAndLog(const BlackMisc::Network::CUrl &url, const BlackMisc::CSlot<void(QNetworkReply *)> &callback);
//! Network reply received, mark in m_urlReadLog
@@ -123,6 +133,8 @@ namespace BlackCore
//! Trigger doWorkImpl
void doWork();
static constexpr int OutdatedPendingCallMs = 30 * 1000; //!< when is a call considered "outdated"
int m_initialTime = -1; //!< Initial start delay
int m_periodicTime = -1; //!< Periodic time after which the task is repeated
QDateTime m_updateTimestamp; //!< when file/resource was read