-
Notifications
You must be signed in to change notification settings - Fork 26
/
recvsolve.cpp
38 lines (35 loc) · 872 Bytes
/
recvsolve.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "recvsolve.h"
#include <QMetaType>
#include <QDebug>
#include <QMutexLocker>
extern QUEUE_DATA<MESG> queue_recv;
void RecvSolve::stopImmediately()
{
QMutexLocker locker(&m_lock);
m_isCanRun = false;
}
RecvSolve::RecvSolve(QObject *par):QThread(par)
{
qRegisterMetaType<MESG *>();
m_isCanRun = true;
}
void RecvSolve::run()
{
WRITE_LOG("start solving data thread: 0x%p", QThread::currentThreadId());
for(;;)
{
{
QMutexLocker locker(&m_lock);
if (m_isCanRun == false)
{
WRITE_LOG("stop solving data thread: 0x%p", QThread::currentThreadId());
return;
}
}
MESG * msg = queue_recv.pop_msg();
if(msg == NULL) continue;
/*else free(msg);
qDebug() << "取出队列:" << msg->msg_type;*/
emit datarecv(msg);
}
}