back to polygonf
git-svn-id: svn://db.shs.com.ru/pip@105 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -123,19 +123,18 @@ bool PIThread::start(int timer_delay) {
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
# ifndef ANDROID
|
||||
pthread_attr_setschedparam(&attr, &sparam);
|
||||
//pthread_attr_setschedparam(&attr, &sparam);
|
||||
# endif
|
||||
if (pthread_create(&thread, &attr, thread_function, this) == 0) {
|
||||
setPriority(priority_);
|
||||
running_ = true;
|
||||
return true;
|
||||
int ret = pthread_create(&thread, &attr, thread_function, this);
|
||||
pthread_attr_destroy(&attr);
|
||||
if (ret == 0) {
|
||||
#else
|
||||
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function, this, 0, 0);
|
||||
if (thread != 0) {
|
||||
#endif
|
||||
setPriority(priority_);
|
||||
running_ = true;
|
||||
return true;
|
||||
#endif
|
||||
} else {
|
||||
thread = 0;
|
||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||
@@ -151,19 +150,18 @@ bool PIThread::startOnce() {
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
# ifndef ANDROID
|
||||
pthread_attr_setschedparam(&attr, &sparam);
|
||||
//pthread_attr_setschedparam(&attr, &sparam);
|
||||
# endif
|
||||
if (pthread_create(&thread, &attr, thread_function_once, this) == 0) {
|
||||
setPriority(priority_);
|
||||
running_ = true;
|
||||
return true;
|
||||
int ret = pthread_create(&thread, &attr, thread_function_once, this);
|
||||
pthread_attr_destroy(&attr);
|
||||
if (ret == 0) {
|
||||
#else
|
||||
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)thread_function_once, this, 0, 0);
|
||||
if (thread != 0) {
|
||||
#endif
|
||||
setPriority(priority_);
|
||||
running_ = true;
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
thread = 0;
|
||||
piCoutObj << "Error: Can`t start new thread:" << errorString();
|
||||
@@ -180,7 +178,9 @@ void PIThread::terminate() {
|
||||
pthread_kill(thread, SIGKILL);
|
||||
# else
|
||||
//pthread_kill(thread, SIGKILL);
|
||||
void * ret(0);
|
||||
pthread_cancel(thread);
|
||||
pthread_join(thread, &ret);
|
||||
# endif
|
||||
#else
|
||||
TerminateThread(thread, 0);
|
||||
@@ -230,6 +230,9 @@ void * PIThread::thread_function(void * t) {
|
||||
if (ct.lockRun) ct.mutex_.unlock();
|
||||
ct.terminating = ct.running_ = false;
|
||||
//cout << "thread " << t << " exiting ... " << endl;
|
||||
#ifndef WINDOWS
|
||||
pthread_detach(ct.thread);
|
||||
#endif
|
||||
ct.thread = 0;
|
||||
#ifndef WINDOWS
|
||||
pthread_exit(0);
|
||||
@@ -261,6 +264,9 @@ void * PIThread::thread_function_once(void * t) {
|
||||
ct.end();
|
||||
ct.terminating = ct.running_ = false;
|
||||
//cout << "thread " << t << " exiting ... " << endl;
|
||||
#ifndef WINDOWS
|
||||
pthread_detach(ct.thread);
|
||||
#endif
|
||||
ct.thread = 0;
|
||||
#ifndef WINDOWS
|
||||
pthread_exit(0);
|
||||
@@ -303,7 +309,7 @@ int PIThread::priority2System(PIThread::Priority p) {
|
||||
void PIThread::setPriority(PIThread::Priority prior) {
|
||||
priority_ = prior;
|
||||
#ifndef WINDOWS
|
||||
if (!running_ && thread != 0) return;
|
||||
if (!running_ && (thread != 0)) return;
|
||||
pthread_getschedparam(thread, &policy_, &sparam);
|
||||
sparam.
|
||||
# ifndef LINUX
|
||||
@@ -314,7 +320,7 @@ void PIThread::setPriority(PIThread::Priority prior) {
|
||||
= priority2System(priority_);
|
||||
pthread_setschedparam(thread, policy_, &sparam);
|
||||
#else
|
||||
if (!running_ && thread != 0) return;
|
||||
if (!running_ && (thread != 0)) return;
|
||||
SetThreadPriority(thread, priority2System(priority_));
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user