mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-07 08:24:47 -04:00
THREAD_CLEAN: Clearly distinguish between a request to stop by terminate() from the actual termination isTerminated()
This commit is contained in:
@@ -309,7 +309,7 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
|
||||
void SDREnumerator::run() {
|
||||
|
||||
std::cout << "SDR enumerator starting." << std::endl;
|
||||
terminated.store(false);
|
||||
|
||||
|
||||
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Scanning local devices, please wait..");
|
||||
SDREnumerator::enumerate_devices("");
|
||||
@@ -323,7 +323,6 @@ void SDREnumerator::run() {
|
||||
}
|
||||
|
||||
std::cout << "Reporting enumeration complete." << std::endl;
|
||||
terminated.store(true);
|
||||
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_DEVICES_READY, "Finished scanning devices.");
|
||||
std::cout << "SDR enumerator done." << std::endl;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
|
||||
static std::vector<SDRDeviceInfo *> *enumerate_devices(std::string remoteAddr = "", bool noInit=false);
|
||||
|
||||
void run();
|
||||
virtual void run();
|
||||
|
||||
static SoapySDR::Kwargs argsStrToKwargs(const std::string &args);
|
||||
static void addRemote(std::string remoteAddr);
|
||||
|
||||
@@ -184,7 +184,7 @@ void SDRPostThread::run() {
|
||||
|
||||
iqDataInQueue->set_max_num_items(0);
|
||||
|
||||
while (!terminated) {
|
||||
while (!stopping) {
|
||||
SDRThreadIQData *data_in;
|
||||
|
||||
iqDataInQueue->pop(data_in);
|
||||
@@ -229,7 +229,7 @@ void SDRPostThread::run() {
|
||||
}
|
||||
|
||||
void SDRPostThread::terminate() {
|
||||
terminated = true;
|
||||
IOThread::terminate();
|
||||
SDRThreadIQData *dummy = new SDRThreadIQData;
|
||||
iqDataInQueue->push(dummy);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
void bindDemodulators(std::vector<DemodulatorInstance *> *demods);
|
||||
void removeDemodulator(DemodulatorInstance *demod);
|
||||
|
||||
void run();
|
||||
void terminate();
|
||||
virtual void run();
|
||||
virtual void terminate();
|
||||
|
||||
void runSingleCH(SDRThreadIQData *data_in);
|
||||
void runPFBCH(SDRThreadIQData *data_in);
|
||||
|
||||
@@ -176,7 +176,7 @@ void SDRThread::readStream(SDRThreadIQDataQueue* iqDataOutQueue) {
|
||||
}
|
||||
}
|
||||
|
||||
while (n_read < nElems && !terminated) {
|
||||
while (n_read < nElems && !stopping) {
|
||||
int n_requested = nElems-n_read;
|
||||
int n_stream_read = device->readStream(stream, buffs, mtElems, flags, timeNs);
|
||||
if ((n_read + n_stream_read) > nElems) {
|
||||
@@ -194,7 +194,7 @@ void SDRThread::readStream(SDRThreadIQDataQueue* iqDataOutQueue) {
|
||||
}
|
||||
}
|
||||
|
||||
if (n_read > 0 && !terminated) {
|
||||
if (n_read > 0 && !stopping) {
|
||||
SDRThreadIQData *dataOut = buffers.getBuffer();
|
||||
|
||||
if (iq_swap.load()) {
|
||||
@@ -225,7 +225,7 @@ void SDRThread::readLoop() {
|
||||
|
||||
updateGains();
|
||||
|
||||
while (!terminated.load()) {
|
||||
while (!stopping.load()) {
|
||||
updateSettings();
|
||||
readStream(iqDataOutQueue);
|
||||
}
|
||||
@@ -360,7 +360,6 @@ void SDRThread::run() {
|
||||
//#endif
|
||||
|
||||
std::cout << "SDR thread starting." << std::endl;
|
||||
terminated.store(false);
|
||||
|
||||
SDRDeviceInfo *activeDev = deviceInfo.load();
|
||||
|
||||
@@ -380,8 +379,8 @@ void SDRThread::run() {
|
||||
|
||||
std::cout << "SDR thread done." << std::endl;
|
||||
|
||||
if (!terminated.load()) {
|
||||
terminated.store(true);
|
||||
if (!stopping.load()) {
|
||||
stopping.store(true);
|
||||
wxGetApp().sdrThreadNotify(SDRThread::SDR_THREAD_TERMINATED, "Done.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
~SDRThread();
|
||||
enum SDRThreadState { SDR_THREAD_MESSAGE, SDR_THREAD_INITIALIZED, SDR_THREAD_TERMINATED, SDR_THREAD_FAILED };
|
||||
|
||||
void run();
|
||||
virtual void run();
|
||||
|
||||
SDRDeviceInfo *getDevice();
|
||||
void setDevice(SDRDeviceInfo *dev);
|
||||
|
||||
Reference in New Issue
Block a user