git-svn-id: svn://db.shs.com.ru/pip@759 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -393,17 +393,44 @@ void PIThread::setPriority(PIThread::Priority prior) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
bool isExists(HANDLE hThread) {
|
||||
//errorClear();
|
||||
//piCout << "isExists" << hThread;
|
||||
DWORD dw = 0;
|
||||
GetExitCodeThread(hThread, &dw);
|
||||
//piCout << ret << dw << errorString();
|
||||
if (dw == STILL_ACTIVE) return true;
|
||||
//piCout << errorString();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool PIThread::waitForFinish(int timeout_msecs) {
|
||||
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "PIThread::waitForFinish" << running_ << terminating << timeout_msecs;
|
||||
if (!running_) return true;
|
||||
if (timeout_msecs < 0) {
|
||||
while (running_)
|
||||
while (running_) {
|
||||
msleep(PIP_MIN_MSLEEP);
|
||||
#ifdef WINDOWS
|
||||
if (!isExists(PRIVATE->thread)) {
|
||||
unlock();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
tmf_.reset();
|
||||
while (running_ && tmf_.elapsed_m() < timeout_msecs)
|
||||
while (running_ && tmf_.elapsed_m() < timeout_msecs) {
|
||||
msleep(PIP_MIN_MSLEEP);
|
||||
#ifdef WINDOWS
|
||||
if (!isExists(PRIVATE->thread)) {
|
||||
unlock();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return tmf_.elapsed_m() < timeout_msecs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user