Move code out of frame, proper thread termination

This commit is contained in:
Charles J. Cliffe
2014-11-23 19:39:27 -05:00
parent ac20bc1e84
commit cae1855fc5
15 changed files with 171 additions and 196 deletions
+25 -8
View File
@@ -3,16 +3,23 @@
DemodulatorInstance::DemodulatorInstance() :
t_Demod(NULL), threadQueueDemod(NULL), demodulatorThread(NULL) {
}
DemodulatorInstance::~DemodulatorInstance() {
delete threadQueueDemod;
delete demodulatorThread;
delete t_Demod;
}
void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
demodulatorThread->setVisualOutputQueue(tQueue);
}
void DemodulatorInstance::init() {
if (threadQueueDemod) {
delete threadQueueDemod;
}
if (demodulatorThread) {
terminate();
delete threadQueueDemod;
delete demodulatorThread;
delete t_Demod;
}
threadQueueDemod = new DemodulatorThreadInputQueue;
@@ -21,16 +28,17 @@ void DemodulatorInstance::init() {
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
}
void DemodulatorInstance::terminate() {
demodulatorThread->terminate();
t_Demod->join();
}
DemodulatorMgr::DemodulatorMgr() {
}
DemodulatorMgr::~DemodulatorMgr() {
while (demods.size()) {
DemodulatorInstance *d = demods.back();
demods.pop_back();
delete d;
}
terminateAll();
}
DemodulatorInstance *DemodulatorMgr::newThread() {
@@ -38,3 +46,12 @@ DemodulatorInstance *DemodulatorMgr::newThread() {
demods.push_back(newDemod);
return newDemod;
}
void DemodulatorMgr::terminateAll() {
while (demods.size()) {
DemodulatorInstance *d = demods.back();
demods.pop_back();
d->terminate();
delete d;
}
}