feat: Make log writing in other thread.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "DmsAsyncAction.h"
|
||||
#include "dms_mq.h"
|
||||
#include "log/LogManager.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@@ -17,7 +18,6 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
||||
, mResponseSignal(aResponseSignal)
|
||||
, mSendData()
|
||||
, mIsResponsed(false)
|
||||
, mIsRunning(false)
|
||||
{
|
||||
mTimer->setSingleShot(true);
|
||||
mTimer->setInterval(TIMEOUT_MSEC);
|
||||
@@ -45,6 +45,7 @@ bool DmsAsyncAction::execute()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Message:%3").arg(mServerId).arg(mActionId).arg(mSendData));
|
||||
mTimer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ private:
|
||||
QString mResponseSignal;
|
||||
QString mSendData;
|
||||
bool mIsResponsed;
|
||||
bool mIsRunning;
|
||||
};
|
||||
|
||||
#endif // DMSASYNCACTION_H
|
||||
|
||||
@@ -25,6 +25,7 @@ DmsSyncAction::DmsSyncAction(int aServerId, int aActionId, QObject* aObject, con
|
||||
{
|
||||
mTimer->setSingleShot(true);
|
||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
||||
connect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
||||
}
|
||||
@@ -49,6 +50,7 @@ DmsSyncActionResult DmsSyncAction::execute()
|
||||
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Message:%3").arg(mServerId).arg(mActionId).arg(mSendData));
|
||||
if(!waitUntilSignalReceived())
|
||||
{
|
||||
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Time out.").arg(mServerId).arg(mActionId));
|
||||
DmsSyncActionResult result(false, "time out");
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user