Last active
June 7, 2016 06:37
-
-
Save sivabudh/8c06389db09cac53dfbff099ab9b499f to your computer and use it in GitHub Desktop.
How to handle thread termination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QTimer* timer = new Qtimer(); | |
connect(timer, SIGNAL(timeout(1)), thread, SLOT(threaCode)); | |
// will get called every 1 milliseconds | |
void threadCode() | |
{ | |
timer->stop(); | |
tryReceiveBytes(5, bytes); | |
if(dead) | |
return; | |
if not receive anything | |
timer->start() | |
return; | |
// received message AND not dead | |
// --> should do processing | |
finally { | |
timer->start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment