pithread, pitimer stop, stopAndWait

This commit is contained in:
Бычков Андрей
2022-11-09 17:17:21 +03:00
parent f9c1ef5ba4
commit d9eac06749
8 changed files with 25 additions and 20 deletions

View File

@@ -274,15 +274,12 @@ bool _PITimerImp_Thread::startTimer(double interval_ms) {
bool _PITimerImp_Thread::stopTimer(bool wait) {
#ifndef FREERTOS
thread_.stop(wait);
#else
thread_.stop();
if (wait)
if (!thread_.waitForFinish(10))
if (thread_.isRunning())
thread_.terminate();
#endif
if (wait) return thread_.waitForFinish();
// if (wait)
// if (!thread_.waitForFinish(10))
// if (thread_.isRunning())
// thread_.terminate();
return true;
}
@@ -739,3 +736,9 @@ bool PITimer::waitForFinish(int timeout_msecs) {
piMinSleep();
return tm.elapsed_m() < timeout_msecs;
}
void PITimer::stopAndWait(int timeout_ms) {
init();
imp->stop(false);
waitForFinish(timeout_ms);
}