Auto status change to "Under Review"
@@ -1,47 +1,45 | |||||
1 | #include "DataSource/DataSourceController.h" |
|
1 | #include "DataSource/DataSourceController.h" | |
2 |
|
2 | |||
3 | #include <QMutex> |
|
3 | #include <QMutex> | |
4 | #include <QThread> |
|
4 | #include <QThread> | |
5 |
|
5 | |||
6 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "dataSourceController") |
|
6 | Q_LOGGING_CATEGORY(LOG_DataSourceController, "dataSourceController") | |
7 |
|
7 | |||
8 | class DataSourceController::DataSourceControllerPrivate { |
|
8 | class DataSourceController::DataSourceControllerPrivate { | |
9 | public: |
|
9 | public: | |
10 | DataSourceControllerPrivate() {} |
|
10 | DataSourceControllerPrivate() {} | |
11 |
|
11 | |||
12 |
|
||||
13 | QMutex m_WorkingMutex; |
|
12 | QMutex m_WorkingMutex; | |
14 | }; |
|
13 | }; | |
15 |
|
14 | |||
16 | DataSourceController::DataSourceController(QObject *parent) |
|
15 | DataSourceController::DataSourceController(QObject *parent) | |
17 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} |
|
16 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} | |
18 | { |
|
17 | { | |
19 |
qC |
|
18 | qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController") | |
|
19 | << QThread::currentThread(); | |||
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | DataSourceController::~DataSourceController() |
|
22 | DataSourceController::~DataSourceController() | |
23 | { |
|
23 | { | |
24 | // delete impl; |
|
24 | qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController") | |
|
25 | << QThread::currentThread(); | |||
25 | this->waitForFinish(); |
|
26 | this->waitForFinish(); | |
26 | } |
|
27 | } | |
27 |
|
28 | |||
28 | void DataSourceController::initialize() |
|
29 | void DataSourceController::initialize() | |
29 | { |
|
30 | { | |
30 |
qC |
|
31 | qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController") | |
|
32 | << QThread::currentThread(); | |||
31 | impl->m_WorkingMutex.lock(); |
|
33 | impl->m_WorkingMutex.lock(); | |
32 |
qC |
|
34 | qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END"); | |
33 | } |
|
35 | } | |
34 |
|
36 | |||
35 | void DataSourceController::finalize() |
|
37 | void DataSourceController::finalize() | |
36 | { |
|
38 | { | |
37 | qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController"); |
|
|||
38 | impl->m_WorkingMutex.unlock(); |
|
39 | impl->m_WorkingMutex.unlock(); | |
39 | qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController END"); |
|
|||
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void DataSourceController::waitForFinish() |
|
42 | void DataSourceController::waitForFinish() | |
43 | { |
|
43 | { | |
44 | qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController"); |
|
|||
45 | QMutexLocker locker(&impl->m_WorkingMutex); |
|
44 | QMutexLocker locker(&impl->m_WorkingMutex); | |
46 | qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController END"); |
|
|||
47 | } |
|
45 | } |
@@ -1,40 +1,46 | |||||
1 | #include "SqpApplication.h" |
|
1 | #include "SqpApplication.h" | |
2 |
|
2 | |||
3 | #include <DataSource/DataSourceController.h> |
|
3 | #include <DataSource/DataSourceController.h> | |
4 | #include <QThread> |
|
4 | #include <QThread> | |
5 |
|
5 | |||
6 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
6 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
7 |
|
7 | |||
8 | class SqpApplication::SqpApplicationPrivate { |
|
8 | class SqpApplication::SqpApplicationPrivate { | |
9 | public: |
|
9 | public: | |
10 | SqpApplicationPrivate() {} |
|
10 | SqpApplicationPrivate() {} | |
|
11 | ~SqpApplicationPrivate() | |||
|
12 | { | |||
|
13 | qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate"); | |||
|
14 | ; | |||
|
15 | m_DataSourceControllerThread.quit(); | |||
|
16 | m_DataSourceControllerThread.wait(); | |||
|
17 | } | |||
11 |
|
18 | |||
12 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
19 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
13 | QThread m_DataSourceControllerThread; |
|
20 | QThread m_DataSourceControllerThread; | |
14 | }; |
|
21 | }; | |
15 |
|
22 | |||
16 |
|
23 | |||
17 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
24 | SqpApplication::SqpApplication(int &argc, char **argv) | |
18 | : QApplication(argc, argv), impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
25 | : QApplication(argc, argv), impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
19 | { |
|
26 | { | |
20 | qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication"); |
|
27 | qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication"); | |
21 |
|
28 | |||
22 | impl->m_DataSourceController = std::make_unique<DataSourceController>(); |
|
29 | impl->m_DataSourceController = std::make_unique<DataSourceController>(); | |
23 | impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread); |
|
30 | impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread); | |
24 |
|
31 | |||
25 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
32 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
26 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
33 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
27 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
34 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
28 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
35 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
29 |
|
36 | |||
30 | impl->m_DataSourceControllerThread.start(); |
|
37 | impl->m_DataSourceControllerThread.start(); | |
31 | } |
|
38 | } | |
32 |
|
39 | |||
33 | SqpApplication::~SqpApplication() |
|
40 | SqpApplication::~SqpApplication() | |
34 | { |
|
41 | { | |
35 | impl->m_DataSourceControllerThread.quit(); |
|
|||
36 | } |
|
42 | } | |
37 |
|
43 | |||
38 | void SqpApplication::initialize() |
|
44 | void SqpApplication::initialize() | |
39 | { |
|
45 | { | |
40 | } |
|
46 | } |
General Comments 4
Status change > Approved
You need to be logged in to leave comments.
Login now