refs #476 CThreadedReader::gracefulShutdown using the worker abandon feature, removed m_shutdown.

This commit is contained in:
Mathew Sutcliffe
2015-11-25 20:35:48 +00:00
parent 1dc4864ffa
commit 3e1eb350c5
7 changed files with 11 additions and 36 deletions

View File

@@ -36,11 +36,6 @@ namespace BlackMisc
return -1;
}
bool CThreadedReader::isFinishedOrShutdown() const
{
return m_shutdown || isFinished();
}
QDateTime CThreadedReader::getUpdateTimestamp() const
{
QReadLocker lock(&this->m_lock);
@@ -53,14 +48,6 @@ namespace BlackMisc
this->m_updateTimestamp = updateTimestamp;
}
void CThreadedReader::requestStop()
{
if (m_updateTimer)
{
QMetaObject::invokeMethod(m_updateTimer, "stop");
}
}
void CThreadedReader::requestReload()
{
// default implementation, subclasses shall override as required
@@ -69,15 +56,11 @@ namespace BlackMisc
void CThreadedReader::gracefulShutdown()
{
if (this->m_shutdown) { return; }
this->m_shutdown = true;
this->requestStop();
this->quit();
this->abandonAndWait();
}
CThreadedReader::~CThreadedReader()
{
this->m_shutdown = true;
}
void CThreadedReader::setInterval(int updatePeriodMs)

View File

@@ -38,10 +38,6 @@ namespace BlackMisc
//! \threadsafe
void setUpdateTimestamp(const QDateTime &updateTimestamp);
//! Request to stop
//! \threadsafe
void requestStop();
//! Request new reading
//! \note override as required, default is to call initialize()
virtual void requestReload();
@@ -65,7 +61,6 @@ namespace BlackMisc
protected:
QTimer *m_updateTimer = nullptr; //!< update timer
std::atomic<bool> m_shutdown { false }; //!< in shutdown process
mutable QReadWriteLock m_lock {QReadWriteLock::Recursive}; //!< lock which can be used from the derived classes
//! Constructor
@@ -74,9 +69,6 @@ namespace BlackMisc
//! When was reply last modified, -1 if N/A
qint64 lastModifiedMsSinceEpoch(QNetworkReply *nwReply) const;
//! Shutdown in progress or finished
bool isFinishedOrShutdown() const;
//! Make sure everthing runs correctly in own thread
void threadAssertCheck() const;