JackTrip: src/ThreadPoolTest.h Source File

JackTrip

ThreadPoolTest.h
Go to the documentation of this file.
1
7 #ifndef __THREADPOOLTEST_H__
8 #define __THREADPOOLTEST_H__
9
10 #include <QThreadPool>
11 #include <QEventLoop>
12 #include <QThread>
13 #include <QObject>
14
15 #include <iostream>
16
17 #include "NetKS.h"
18 #include "JackTripWorkerMessages.h"
19
20
21 class ThreadPoolTest : public QObject, public QRunnable
22 //class ThreadPoolTest : public QThread
23 {
24 Q_OBJECT;
25
26 public:
27 ThreadPoolTest()
28 {
29 setAutoDelete(false);
30 }
31
32 void run()
33 {
34 JackTripWorkerMessages jtm;
35 QThread testThread;
36 //jtm.moveToThread(&testThread);
37
38 //QObject::connect(&jtm, SIGNAL(signalTest()), &jtm, SLOT(slotTest()), Qt::QueuedConnection);
39 testThread.start();
40 jtm.play();
41 //testThread.wait();
42
43 //std::cout << "--------------- BEFORE ---------------" << std::endl;
44 //NetKS netks;
45 //netks.play();
46 //std::cout << "--------------- AFTER ---------------" << std::endl;
47
48 QEventLoop loop;
49 //QObject::connect(this, SIGNAL(stopELoop()), &loop, SLOT(quit()), Qt::QueuedConnection);
50 loop.exec();
51 //std::cout << "--------------- EXITING QRUNNABLE---------------" << std::endl;
52 /*
53 while (true) {
54 std::cout << "Hello world from thread" << std::endl;
55 sleep(1);
56 }
57 */
58 }
59
60 void stop()
61 {
62 std::cout << "--------------- ELOOP STOP---------------" << std::endl;
63 emit stopELoop();
64 }
65
66 signals:
67 void stopELoop();
68
69 private slots:
70 void fromServer()
71 {
72 std::cout << "--------------- SIGNAL RECEIVED ---------------" << std::endl;
73 }
74
75 };
76
77 #endif //__THREADPOOLTEST_H__
NetKS.h
ThreadPoolTest::stopELoop
void stopELoop()
Definition: moc_ThreadPoolTest.cpp:134
ThreadPoolTest
Definition: ThreadPoolTest.h:21
ThreadPoolTest::stop
void stop()
Definition: ThreadPoolTest.h:60
JackTripWorkerMessages
Definition: JackTripWorkerMessages.h:46
ThreadPoolTest::run
void run()
Definition: ThreadPoolTest.h:32
JackTripWorkerMessages.h
JackTripWorkerMessages::play
void play()
Definition: JackTripWorkerMessages.h:54
ThreadPoolTest::ThreadPoolTest
ThreadPoolTest()
Definition: ThreadPoolTest.h:27