Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Create Processing Thread in Server Class

$
0
0
I have a problem in my server class where I create a thread which is used for processing incoming data, however, once the thread is running it will block the signals from emitting for my socket. Here is a overview of my class: Class cUdpServer {   QUdpSocket * mUdpSocket; QThread * mProcessingThread;   Connect() {   State = PROCESSING_DATA;   Create Processing Thread   Connect started signal to OnProcessing   Thread->start()     Create Udp Socket   Connect readReady signal to OnNewData   Bind and Begin Listening }   OnNewData() {   Read Incoming Data   Insert new data into circular buffer }   OnProcessing() {   while( State == PROCESSING_DATA )   {     Check if new data available in circular buffer     If available begin parsing data   } }   } However, if I start the thread I never receive data because the signal readReady is never emitted, but if I do not start the thread I receive data just fine. I did fix the problem by inheriting the QThread class and everything seems to work fine, however, my question is how would I get this to work with using the QThread as a class member? The reason I have the processing in a forever loop is because I constantly receive new data on the socket, is a looped thread the best way to implement the design, or would destroying and restarting the thread at each new processing better? Thanks a lot for any insight into this! [Added code markup, Tobias]

Viewing all articles
Browse latest Browse all 18427

Trending Articles