git-svn-id: svn://db.shs.com.ru/pip@758 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-02-19 09:10:12 +00:00
parent dd1079bcef
commit 84a584c682
5 changed files with 42 additions and 40 deletions

View File

@@ -211,7 +211,7 @@ PIThread::~PIThread() {
void PIThread::stop(bool wait) {
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop ..." << running_ << wait;
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop ..." << running_ << wait;
terminating = true;
if (wait) waitForFinish();
}
@@ -307,7 +307,7 @@ bool PIThread::startOnce() {
void PIThread::terminate() {
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "terminate ..." << running_;
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "terminate ..." << running_;
#ifdef FREERTOS
PICout(PICoutManipulators::DefaultControls) << "FreeRTOS can't terminate pthreads! waiting for stop";
stop(true);
@@ -335,7 +335,7 @@ void PIThread::terminate() {
PRIVATE->thread = 0;
end();
#endif
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "terminate ok" << running_;
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "terminate ok" << running_;
}
@@ -394,7 +394,7 @@ void PIThread::setPriority(PIThread::Priority prior) {
bool PIThread::waitForFinish(int timeout_msecs) {
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "PIThread::waitForFinish" << running_ << terminating << timeout_msecs;
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "PIThread::waitForFinish" << running_ << terminating << timeout_msecs;
if (!running_) return true;
if (timeout_msecs < 0) {
while (running_)
@@ -445,23 +445,23 @@ void PIThread::__thread_func__() {
if (lockRun) mutex_.unlock();
started();
while (!terminating) {
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "queued" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "queued" << "...";
maybeCallQueuedEvents();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "queued" << "ok";
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "queued" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "...";
if (lockRun) mutex_.lock();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "ok";
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "run" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "lock" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "run" << "...";
run();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "run" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "run" << "ok";
//printf("thread %p tick\n", this);
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "ret_func" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "ret_func" << "...";
if (ret_func != 0) ret_func(data_);
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "ret_func" << "ok";
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "ret_func" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "...";
if (lockRun) mutex_.unlock();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "ok";
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "unlock" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "...";
if (delay_ > 0) {
tmr_.reset();
double sl(0.);
@@ -479,19 +479,19 @@ void PIThread::__thread_func__() {
piMSleep(sl);
}
}
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "ok";
}
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "...";
stopped();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
if (lockRun) mutex_.lock();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "end" << "...";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "end" << "...";
end();
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop" << "ok";
if (lockRun) mutex_.unlock();
terminating = running_ = false;
tid_ = -1;
PICout(PICoutManipulators::DefaultControls) << "thread" << this << "exit";
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "exit";
//cout << "thread " << t << " exiting ... " << endl;
//PICout(PICoutManipulators::DefaultControls) << "pthread_exit" << (__privateinitializer__.p)->thread;
UNREGISTER_THREAD(this);