refactor: Add asserts to check executing in worker thread

This commit is contained in:
Lars Toenning
2025-06-09 14:21:45 +02:00
parent 0d1e8a0783
commit b9cdccec05
4 changed files with 4 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ namespace swift::core::db
void CDatabaseReader::readInBackgroundThread(CEntityFlags::Entity entities, const QDateTime &newerThan) void CDatabaseReader::readInBackgroundThread(CEntityFlags::Entity entities, const QDateTime &newerThan)
{ {
if (!this->doWorkCheck()) { return; } if (!this->doWorkCheck()) { return; }
Q_ASSERT_X(hasStarted(), Q_FUNC_INFO, "Thread was not started yet!");
// we accept cached data // we accept cached data
Q_ASSERT_X(!entities.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO, "Read info objects directly"); Q_ASSERT_X(!entities.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO, "Read info objects directly");

View File

@@ -13,6 +13,7 @@ namespace swift::core
void CThreadedReaderPeriodic::startReader() void CThreadedReaderPeriodic::startReader()
{ {
Q_ASSERT_X(hasStarted(), Q_FUNC_INFO, "Thread was not started yet!");
Q_ASSERT(m_initialTime > 0); Q_ASSERT(m_initialTime > 0);
QTimer::singleShot(m_initialTime, this, [=] { this->doWork(); }); QTimer::singleShot(m_initialTime, this, [=] { this->doWork(); });
} }

View File

@@ -36,6 +36,7 @@ namespace swift::core::vatsim
void CVatsimServerFileReader::readInBackgroundThread() void CVatsimServerFileReader::readInBackgroundThread()
{ {
Q_ASSERT_X(hasStarted(), Q_FUNC_INFO, "Thread was not started yet!");
QPointer<CVatsimServerFileReader> myself(this); QPointer<CVatsimServerFileReader> myself(this);
QTimer::singleShot(0, this, [=] { QTimer::singleShot(0, this, [=] {
if (!myself) { return; } if (!myself) { return; }

View File

@@ -38,6 +38,7 @@ namespace swift::core::vatsim
void CVatsimStatusFileReader::readInBackgroundThread() void CVatsimStatusFileReader::readInBackgroundThread()
{ {
Q_ASSERT_X(hasStarted(), Q_FUNC_INFO, "Thread was not started yet!");
QPointer<CVatsimStatusFileReader> myself(this); QPointer<CVatsimStatusFileReader> myself(this);
QTimer::singleShot(0, this, [=] { QTimer::singleShot(0, this, [=] {
if (!myself) { return; } if (!myself) { return; }