MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / isTerminated

Method isTerminated

src/IOThread.cpp:101–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool IOThread::isTerminated(int waitMs) {
102
103 if (terminated.load()) {
104 return true;
105 }
106 else if (waitMs == 0) {
107 return false;
108 }
109
110 //this is a stupid busy plus sleep loop
111 int nbCyclesToWait;
112
113 if (waitMs < 0) {
114 nbCyclesToWait = std::numeric_limits<int>::max();
115 }
116 else {
117 nbCyclesToWait = (waitMs / SPIN_WAIT_SLEEP_MS) + 1;
118 }
119
120 for ( int i = 0; i < nbCyclesToWait; i++) {
121
122 std::this_thread::sleep_for(std::chrono::milliseconds(SPIN_WAIT_SLEEP_MS));
123
124 if (terminated.load()) {
125 return true;
126 }
127 }
128
129 std::cout << "ERROR: thread '" << typeid(*this).name() << "' has not terminated in time ! (> " << waitMs << " ms)" << std::endl << std::flush;
130
131 return terminated.load();
132}

Callers 15

OnExitMethod · 0.45
setOffsetMethod · 0.45
setAntennaNameMethod · 0.45
setChannelizerTypeMethod · 0.45
getChannelizerTypeMethod · 0.45
lockFrequencyMethod · 0.45
unlockFrequencyMethod · 0.45
setSampleRateMethod · 0.45
stopDeviceMethod · 0.45
setDeviceMethod · 0.45
setPPMMethod · 0.45
areDevicesEnumeratingMethod · 0.45

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected