refs #476, improvements on gracefulShutdown

* gracefulShutdown in metar reader and other readers
* made m_shutdown thread safe
* Demoted log level for reader
* helper function finished or shutdown
This commit is contained in:
Klaus Basan
2015-11-07 18:51:10 +01:00
committed by Mathew Sutcliffe
parent 54448fd2b2
commit 4d3d9fa6be
8 changed files with 28 additions and 15 deletions

View File

@@ -21,6 +21,7 @@
#include <QTimer>
#include <QNetworkReply>
#include <QCoreApplication>
#include <atomic>
namespace BlackMisc
{
@@ -57,16 +58,20 @@ namespace BlackMisc
int interval() const;
//! Graceful shutdown
//! \threadsafe
void gracefulShutdown();
protected:
//! Constructor
CThreadedReader(QObject *owner, const QString &name);
QTimer *m_updateTimer = nullptr; //!< update timer
bool m_shutdown = false; //!< in shutdown process
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
//! Shutdown in progress or finished
bool isFinishedOrShutdown() const;
//! Make sure everthing runs correctly in own thread
void threadAssertCheck() const;