-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextentqthread.cpp
More file actions
57 lines (44 loc) · 1.88 KB
/
extentqthread.cpp
File metadata and controls
57 lines (44 loc) · 1.88 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "extentqthread.h"
extern long baseMSecsSinceEpoch;
ExtentQThread::ExtentQThread(QString name_, long loopTimeoutMsec_)
{
name = name_;
loopTimeoutMsec = loopTimeoutMsec_;
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "loopTimeoutMsec" << loopTimeoutMsec
<< "created on thread" << QThread::currentThreadId();
}
void ExtentQThread::run() {
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "STARTED on thread" << QThread::currentThreadId();
ExtentQObject extQObject("extQObject created from (" + name + ")");
connect(this, &ExtentQThread::runFirstSlot, &extQObject, &ExtentQObject::onExtentQObjectFirstSlot);
if (loopTimeoutMsec < 0) {
while(1) {};
} else {
QThread::msleep(loopTimeoutMsec);
}
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "before exec() on thread" << QThread::currentThreadId();
exec();
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "after exec() on thread" << QThread::currentThreadId();
if (loopTimeoutMsec < 0) {
while(1) {};
} else {
QThread::msleep(loopTimeoutMsec);
}
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "STOPPED on thread" << QThread::currentThreadId();
}
void ExtentQThread::onExtentQThreadFirstSlot() {
qDebug() << QDateTime::currentMSecsSinceEpoch() - baseMSecsSinceEpoch << Q_FUNC_INFO
<< "instance" << name
<< "run on thread" << QThread::currentThreadId();
Q_EMIT runFirstSlot();
}