-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestClass.cpp
57 lines (44 loc) · 1.08 KB
/
TestClass.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "TestClass.h"
#include <QDebug>
TestClass::TestClass(QObject *parent) :
QObject {parent}
{}
TestClass::~TestClass()
{
_pthread_cleanup_dest(m_thread);
}
qint64
TestClass::worker1()
{
qDebug() << Q_FUNC_INFO << "Invoked";
if(m_numbers.empty()) return 0;
return std::accumulate(m_numbers.begin(), m_numbers.end(), 1, std::multiplies<qint64>());
}
qint64
TestClass::worker2(const std::vector<int> &numbers)
{
qDebug() << Q_FUNC_INFO << "Invoked";
if(numbers.empty()) return 0;
return std::accumulate(numbers.begin(), numbers.end(), 1, std::multiplies<qint64>());
}
void
TestClass::runWorker1()
{
Spthread::run(m_thread, this, &TestClass::worker1);
}
void
TestClass::runWorker2()
{
Spthread::run(m_thread, this, &TestClass::worker2, m_numbers);
}
void
TestClass::runWorker2_2()
{
std::vector<int> numbers = {10, 20, 30, 40, 50, 60, 70, 80, 90};
Spthread::run(m_thread, this, &TestClass::worker2, numbers);
}
void
TestClass::runWorker2_3(const std::vector<int> &numbers)
{
Spthread::run(m_thread, this, &TestClass::worker2, numbers);
}