JackTrip
|
00001 00007 #ifndef __THREADPOOLTEST_H__ 00008 #define __THREADPOOLTEST_H__ 00009 00010 #include <QThreadPool> 00011 #include <QEventLoop> 00012 #include <QThread> 00013 #include <QObject> 00014 00015 #include <iostream> 00016 00017 #include "NetKS.h" 00018 #include "JackTripWorkerMessages.h" 00019 00020 00021 class ThreadPoolTest : public QObject, public QRunnable 00022 //class ThreadPoolTest : public QThread 00023 { 00024 Q_OBJECT; 00025 00026 public: 00027 ThreadPoolTest() 00028 { 00029 setAutoDelete(false); 00030 } 00031 00032 void run() 00033 { 00034 JackTripWorkerMessages jtm; 00035 QThread testThread; 00036 //jtm.moveToThread(&testThread); 00037 00038 //QObject::connect(&jtm, SIGNAL(signalTest()), &jtm, SLOT(slotTest()), Qt::QueuedConnection); 00039 testThread.start(); 00040 jtm.play(); 00041 //testThread.wait(); 00042 00043 //std::cout << "--------------- BEFORE ---------------" << std::endl; 00044 //NetKS netks; 00045 //netks.play(); 00046 //std::cout << "--------------- AFTER ---------------" << std::endl; 00047 00048 QEventLoop loop; 00049 //QObject::connect(this, SIGNAL(stopELoop()), &loop, SLOT(quit()), Qt::QueuedConnection); 00050 loop.exec(); 00051 //std::cout << "--------------- EXITING QRUNNABLE---------------" << std::endl; 00052 /* 00053 while (true) { 00054 std::cout << "Hello world from thread" << std::endl; 00055 sleep(1); 00056 } 00057 */ 00058 } 00059 00060 void stop() 00061 { 00062 std::cout << "--------------- ELOOP STOP---------------" << std::endl; 00063 emit stopELoop(); 00064 } 00065 00066 signals: 00067 void stopELoop(); 00068 00069 private slots: 00070 void fromServer() 00071 { 00072 std::cout << "--------------- SIGNAL RECEIVED ---------------" << std::endl; 00073 } 00074 00075 }; 00076 00077 #endif //__THREADPOOLTEST_H__