remove msleep, clean PIConditionVariable, rewrite pipipelinethread, etc...

This commit is contained in:
Andrey
2021-10-29 16:52:03 +03:00
parent 21e03fc8cb
commit 6e5a5a6ade
16 changed files with 203 additions and 213 deletions

View File

@@ -63,7 +63,7 @@ event started();
while (isRunning()) {
run();
ThreadFunc();
msleep(timer_delay);
piMSleep(timer_delay);
}
event stopped();
end();
@@ -402,7 +402,7 @@ bool PIThread::waitForFinish(int timeout_msecs) {
if (!running_) return true;
if (timeout_msecs < 0) {
while (running_) {
msleep(PIP_MIN_MSLEEP);
piMSleep(PIP_MIN_MSLEEP);
#ifdef WINDOWS
if (!isExists(PRIVATE->thread)) {
unlock();
@@ -414,7 +414,7 @@ bool PIThread::waitForFinish(int timeout_msecs) {
}
tmf_.reset();
while (running_ && tmf_.elapsed_m() < timeout_msecs) {
msleep(PIP_MIN_MSLEEP);
piMSleep(PIP_MIN_MSLEEP);
#ifdef WINDOWS
if (!isExists(PRIVATE->thread)) {
unlock();
@@ -430,12 +430,12 @@ bool PIThread::waitForStart(int timeout_msecs) {
if (running_) return true;
if (timeout_msecs < 0) {
while (!running_)
msleep(PIP_MIN_MSLEEP);
piMSleep(PIP_MIN_MSLEEP);
return true;
}
tms_.reset();
while (!running_ && tms_.elapsed_m() < timeout_msecs)
msleep(PIP_MIN_MSLEEP);
piMSleep(PIP_MIN_MSLEEP);
return tms_.elapsed_m() < timeout_msecs;
}
@@ -456,9 +456,9 @@ void PIThread::_beginThread() {
PIINTROSPECTION_THREAD_START(this);
REGISTER_THREAD(this);
running_ = true;
if (lockRun) mutex_.lock();
if (lockRun) thread_mutex.lock();
begin();
if (lockRun) mutex_.unlock();
if (lockRun) thread_mutex.unlock();
started();
}
@@ -466,7 +466,7 @@ void PIThread::_beginThread() {
void PIThread::_runThread() {
PIINTROSPECTION_THREAD_RUN(this);
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "...";
if (lockRun) mutex_.lock();
if (lockRun) thread_mutex.lock();
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "run" << "...";
#ifdef PIP_INTROSPECTION
@@ -482,7 +482,7 @@ void PIThread::_runThread() {
if (ret_func != 0) ret_func(data_);
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "ret_func" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "...";
if (lockRun) mutex_.unlock();
if (lockRun) thread_mutex.unlock();
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "ok";
}
@@ -491,11 +491,11 @@ void PIThread::_endThread() {
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "...";
stopped();
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
if (lockRun) mutex_.lock();
if (lockRun) thread_mutex.lock();
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "end" << "...";
end();
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
if (lockRun) mutex_.unlock();
if (lockRun) thread_mutex.unlock();
terminating = running_ = false;
tid_ = -1;
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "exit";