mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 15:25:34 +08:00
Track worker construction and destruction
Added debug log messages in case a worker still exists when the `qApp` is destroyed. This would mean that a `quitAndWait` is missing or is being skipped somewhere.
This commit is contained in:
@@ -163,6 +163,9 @@ namespace BlackMisc
|
||||
//! Convenience to call abandon() followed by waitForFinished().
|
||||
void abandonAndWait() noexcept;
|
||||
|
||||
//! All workers currently existing.
|
||||
static const QSet<CWorkerBase *> &allWorkers() { return s_allWorkers; }
|
||||
|
||||
signals:
|
||||
//! Emitted when the task is about to start.
|
||||
void aboutToStart();
|
||||
@@ -172,6 +175,12 @@ namespace BlackMisc
|
||||
void finished();
|
||||
|
||||
protected:
|
||||
//! Constructor.
|
||||
CWorkerBase();
|
||||
|
||||
//! Destructor.
|
||||
virtual ~CWorkerBase() override;
|
||||
|
||||
//! For the task to check whether it can finish early.
|
||||
//! \threadsafe
|
||||
bool isAbandoned() const;
|
||||
@@ -197,6 +206,7 @@ namespace BlackMisc
|
||||
bool m_started = false;
|
||||
bool m_finished = false;
|
||||
mutable QMutex m_finishedMutex { QMutex::Recursive };
|
||||
static QSet<CWorkerBase *> s_allWorkers;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user