mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
* URLs no longer have to be passed * watchdog for DB readers to check DB status In same step: * fixed some log messages and comments * allow to self signed SSL certificates * adjusted namespace for CNetworkUtils (now in network)
79 lines
2.3 KiB
C++
79 lines
2.3 KiB
C++
/* Copyright (C) 2013
|
|
* swift project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef BLACKMISC_THREADED_READER_H
|
|
#define BLACKMISC_THREADED_READER_H
|
|
|
|
//! \file
|
|
|
|
#include "blackmiscexport.h"
|
|
#include "blackmisc/network/urllist.h"
|
|
#include "blackmisc/network/entityflags.h"
|
|
#include "worker.h"
|
|
#include <QReadWriteLock>
|
|
#include <QDateTime>
|
|
#include <QTimer>
|
|
#include <QNetworkReply>
|
|
#include <QCoreApplication>
|
|
|
|
namespace BlackMisc
|
|
{
|
|
//! Support for threaded based reading and parsing tasks such
|
|
//! as data files via http, or file system and parsing (such as FSX models)
|
|
class BLACKMISC_EXPORT CThreadedReader : public CContinuousWorker
|
|
{
|
|
public:
|
|
//! Thread safe, set update timestamp
|
|
//! \threadsafe
|
|
QDateTime getUpdateTimestamp() const;
|
|
|
|
//! Thread safe, set update timestamp
|
|
//! \threadsafe
|
|
void setUpdateTimestamp(const QDateTime &updateTimestamp);
|
|
|
|
//! Request to stop
|
|
//! \threadsafe
|
|
void requestStop();
|
|
|
|
//! Destructor
|
|
virtual ~CThreadedReader();
|
|
|
|
//! \copydoc CContinuousWorker::cleanup
|
|
virtual void cleanup() override;
|
|
|
|
//! Set the update time
|
|
//! \param updatePeriodMs <=0 stops the timer
|
|
//! \threadsafe
|
|
void setInterval(int updatePeriodMs);
|
|
|
|
//! Get the timer interval (ms)
|
|
//! \threadsafe
|
|
int interval() const;
|
|
|
|
//! Graceful shutdown
|
|
void gracefulShutdown();
|
|
|
|
protected:
|
|
//! Constructor
|
|
CThreadedReader(QObject *owner, const QString &name);
|
|
|
|
QTimer *m_updateTimer = nullptr; //!< update timer
|
|
bool m_shutdown = false; //!< in shutdown process
|
|
mutable QReadWriteLock m_lock {QReadWriteLock::Recursive}; //!< lock which can be used from the derived classes
|
|
|
|
//! Make sure everthing runs correctly in own thread
|
|
void threadAssertCheck() const;
|
|
|
|
private:
|
|
QDateTime m_updateTimestamp; //!< when file/resource was read
|
|
};
|
|
} // namespace
|
|
|
|
#endif // guard
|