RTOS work threads

git-svn-id: svn://db.shs.com.ru/pip@687 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2019-02-05 15:40:22 +00:00
parent b7ef5bfdcb
commit 30973842d1
10 changed files with 128 additions and 20 deletions

View File

@@ -40,6 +40,12 @@ __THREAD_FUNC_RET__ thread_function_once(void * t) {PIThread::__thread_func_once
#define REGISTER_THREAD(t) __PIThreadCollection::instance()->registerThread(t)
#define UNREGISTER_THREAD(t) __PIThreadCollection::instance()->unregisterThread(t)
#ifdef FREERTOS
# define PTHREAD_MIN_MSLEEP 10.
#else
# define PTHREAD_MIN_MSLEEP 1.
#endif
/*! \class PIThread
* \brief Thread class
* \details This class allow you exec your code in separate thread.
@@ -286,7 +292,7 @@ void PIThread::terminate() {
PIINTROSPECTION_UNREGISTER_THREAD(tid());
terminating = running_ = false;
tid_ = -1;
//piCout << "terminate" << thread;
//piCout << "terminate" << PRIVATE->thread;
#ifndef WINDOWS
# ifdef ANDROID
pthread_kill(PRIVATE->thread, SIGTERM);
@@ -423,7 +429,7 @@ void PIThread::__thread_func__(void * t) {
ct.tmr_.reset();
double sl(0.);
while (1) {
sl = piMind(ct.delay_ - ct.tmr_.elapsed_m(), 2.);
sl = piMind(ct.delay_ - ct.tmr_.elapsed_m(), PTHREAD_MIN_MSLEEP);
#ifdef WINDOWS
/*if (sl <= 1. && sl >= 0.) {
piMSleep(1.);
@@ -431,10 +437,9 @@ void PIThread::__thread_func__(void * t) {
}*/
#endif
//printf("%f %f %f\n", double(ct.delay_), ct.tmr_.elapsed_m(), sl);
if (ct.terminating) break;
if (sl <= 0.) break;
piMSleep(sl);
if (ct.terminating)
break;
}
}
}
@@ -511,3 +516,4 @@ void PIThread::__thread_func_once__(void * t) {
# endif
#endif
}