mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
Ref T160, continous worker now CIdentifiable and name is mandatory
This commit is contained in:
@@ -258,7 +258,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
CDataCacheSerializer::CDataCacheSerializer(CDataCache *owner, const QString &revisionFileName) :
|
||||
CContinuousWorker(owner),
|
||||
CContinuousWorker(owner, QString("CDataCacheSerializer '%1'").arg(revisionFileName)),
|
||||
m_cache(owner),
|
||||
m_revisionFileName(revisionFileName)
|
||||
{}
|
||||
|
||||
@@ -117,9 +117,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
CContinuousWorker::CContinuousWorker(QObject *owner, const QString &name) :
|
||||
CIdentifiable(name),
|
||||
m_owner(owner), m_name(name)
|
||||
{
|
||||
if (m_name.isEmpty()) { m_name = metaObject()->className(); }
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Empty name");
|
||||
setObjectName(m_name);
|
||||
m_updateTimer.setObjectName(m_name + ":timer");
|
||||
}
|
||||
@@ -208,5 +209,4 @@ namespace BlackMisc
|
||||
QMetaObject::invokeMethod(ownThread, "deleteLater");
|
||||
QMetaObject::invokeMethod(this, "deleteLater");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/invoke.h"
|
||||
#include "blackmisc/stacktrace.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
@@ -266,7 +267,9 @@ namespace BlackMisc
|
||||
/*!
|
||||
* Base class for a long-lived worker object which lives in its own thread.
|
||||
*/
|
||||
class BLACKMISC_EXPORT CContinuousWorker : public CWorkerBase
|
||||
class BLACKMISC_EXPORT CContinuousWorker :
|
||||
public CWorkerBase,
|
||||
public CIdentifiable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -276,7 +279,7 @@ namespace BlackMisc
|
||||
* \param owner Will be the parent of the new thread (the worker has no parent).
|
||||
* \param name A name for the worker, which will be used to create a name for the thread.
|
||||
*/
|
||||
CContinuousWorker(QObject *owner, const QString &name = "");
|
||||
CContinuousWorker(QObject *owner, const QString &name);
|
||||
|
||||
//! Starts a thread and moves the worker into it.
|
||||
void start(QThread::Priority priority = QThread::InheritPriority);
|
||||
|
||||
Reference in New Issue
Block a user