mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-27 14:03:15 -04:00
Move code out of frame, proper thread termination
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user