diff --git a/CMakeLists.txt b/CMakeLists.txt index bff4290e..eeb11129 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(pip) set(pip_MAJOR 2) -set(pip_MINOR 32) +set(pip_MINOR 33) set(pip_REVISION 0) set(pip_SUFFIX ) set(pip_COMPANY SHS) diff --git a/libs/main/core/pibase.h b/libs/main/core/pibase.h index d89d525e..8c978f93 100644 --- a/libs/main/core/pibase.h +++ b/libs/main/core/pibase.h @@ -285,10 +285,10 @@ #define FOREVER for (;;) //! Macro used for infinite wait -#define FOREVER_WAIT FOREVER msleep(PIP_MIN_MSLEEP); +#define FOREVER_WAIT FOREVER piMinSleep; //! Macro used for infinite wait -#define WAIT_FOREVER FOREVER msleep(PIP_MIN_MSLEEP); +#define WAIT_FOREVER FOREVER piMinSleep; //! global variable enabling output to piCout, default is true diff --git a/libs/main/core/piobject.cpp b/libs/main/core/piobject.cpp index 5a2c0eb6..7a7ae457 100644 --- a/libs/main/core/piobject.cpp +++ b/libs/main/core/piobject.cpp @@ -749,7 +749,7 @@ void PIObject::Deleter::deleteObject(PIObject * o) { //piCout << "[Deleter] delete" << (uintptr_t)o << "..."; if (o->isPIObject()) { //piCout << "[Deleter] delete" << (uintptr_t)o << "wait atomic ..."; - while (o->isInEvent()) piMSleep(PIP_MIN_MSLEEP); + while (o->isInEvent()) piMinSleep(); //piCout << "[Deleter] delete" << (uintptr_t)o << "wait atomic done"; delete o; } diff --git a/libs/main/core/pitime.h b/libs/main/core/pitime.h index 8416ab70..316811ed 100644 --- a/libs/main/core/pitime.h +++ b/libs/main/core/pitime.h @@ -46,6 +46,8 @@ inline void piMSleep(double msecs) {piUSleep(int(msecs * 1000.));} // on !Window * \details This function exec \a piUSleep (msecs * 1000000). */ inline void piSleep(double secs) {piUSleep(int(secs * 1000000.));} // on !Windows consider constant "usleep" offset +//! Shortest available on current system sleep +inline void piMinSleep() {piMSleep(PIP_MIN_MSLEEP);} diff --git a/libs/main/io_devices/piethernet.cpp b/libs/main/io_devices/piethernet.cpp index 2277184b..7f2e797e 100644 --- a/libs/main/io_devices/piethernet.cpp +++ b/libs/main/io_devices/piethernet.cpp @@ -686,7 +686,7 @@ int PIEthernet::readDevice(void * read_to, int max_size) { s = accept(sock, (sockaddr * )&client_addr, &slen); if (s == -1) { //piCoutObj << "Can`t accept new connection, " << ethErrorString(); - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return -1; } rs = ethRecv(s, read_to, max_size); @@ -788,7 +788,7 @@ int PIEthernet::writeDevice(const void * data, int max_size) { //piCoutObj << "connect SingleTCP" << ip_s << ":" << port_s << "..."; if (::connect(sock, (sockaddr * )&PRIVATE->addr_, sizeof(PRIVATE->addr_)) != 0) { //piCoutObj << "Can`t connect to " << ip_s << ":" << port_s << ", " << ethErrorString(); - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return -1; } //piCoutObj << "ok, write SingleTCP" << int(data) << max_size << "bytes ..."; diff --git a/libs/main/io_devices/piiodevice.cpp b/libs/main/io_devices/piiodevice.cpp index 62d14038..7e1c1863 100644 --- a/libs/main/io_devices/piiodevice.cpp +++ b/libs/main/io_devices/piiodevice.cpp @@ -254,7 +254,7 @@ void PIIODevice::write_func() { int ret = write(item.first); threadedWriteEvent(item.second, ret); } - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); } } @@ -338,7 +338,7 @@ PIByteArray PIIODevice::readForTime(double timeout_ms) { tm.reset(); while (tm.elapsed_m() < timeout_ms) { ret = read(td, threaded_read_buffer_size); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else str.append(td, ret); } delete[] td; diff --git a/libs/main/io_devices/piserial.cpp b/libs/main/io_devices/piserial.cpp index 0c4c64fa..33484c1b 100644 --- a/libs/main/io_devices/piserial.cpp +++ b/libs/main/io_devices/piserial.cpp @@ -434,7 +434,7 @@ bool PISerial::read(void * data, int size, double timeout_ms) { while (all < size && tm_.elapsed_m() < timeout_ms) { ret = readDevice(&((uchar * )data)[all], size - all); if (ret > 0) all += ret; - else piMSleep(PIP_MIN_MSLEEP); + else piMinSleep(); } setOption(BlockingRead, br); received(data, all); @@ -473,13 +473,13 @@ PIString PISerial::read(int size, double timeout_ms) { if (size <= 0) { while (tm_.elapsed_m() < timeout_ms) { ret = readDevice(td, 1024); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else str << PIString((char*)td, ret); } } else { while (all < size && tm_.elapsed_m() < timeout_ms) { ret = readDevice(td, size - all); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else { str << PIString((char*)td, ret); all += ret; @@ -493,7 +493,7 @@ PIString PISerial::read(int size, double timeout_ms) { str << PIString((char*)td, all); while (all < size) { ret = readDevice(td, size - all); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else { str << PIString((char*)td, ret); all += ret; @@ -525,13 +525,13 @@ PIByteArray PISerial::readData(int size, double timeout_ms) { if (size <= 0) { while (tm_.elapsed_m() < timeout_ms) { ret = readDevice(td, 1024); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else str.append(td, ret); } } else { while (all < size && tm_.elapsed_m() < timeout_ms) { ret = readDevice(td, size - all); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else { str.append(td, ret); all += ret; @@ -545,7 +545,7 @@ PIByteArray PISerial::readData(int size, double timeout_ms) { str.append(td, all); while (all < size) { ret = readDevice(td, size - all); - if (ret <= 0) piMSleep(PIP_MIN_MSLEEP); + if (ret <= 0) piMinSleep(); else { str.append(td, ret); all += ret; diff --git a/libs/main/io_utils/pibasetransfer.cpp b/libs/main/io_utils/pibasetransfer.cpp index 1b2f9bf2..7f18c752 100644 --- a/libs/main/io_utils/pibasetransfer.cpp +++ b/libs/main/io_utils/pibasetransfer.cpp @@ -346,7 +346,7 @@ bool PIBaseTransfer::send_process() { if (chk == 0) return finish_send(true); if (chk != prev_chk) rtm.reset(); else if (rtm.elapsed_m() < 100) { - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); continue; } if (is_pause) { @@ -507,7 +507,7 @@ bool PIBaseTransfer::getStartRequest() { return true; } mutex_session.unlock(); - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); } return false; } diff --git a/libs/main/system/piprocess.cpp b/libs/main/system/piprocess.cpp index 2f00d975..7158ddcd 100644 --- a/libs/main/system/piprocess.cpp +++ b/libs/main/system/piprocess.cpp @@ -66,7 +66,7 @@ void PIProcess::exec_() { startOnce(); //cout << "exec wait" << endl; while (!is_exec) - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); //cout << "exec end" << endl; } @@ -172,7 +172,7 @@ void PIProcess::startProc(bool detached) { if (execve(str.data(), a, e) < 0) piCoutObj << "\"execve" << str << args << "\" error :" << errorString(); } else { - msleep(PIP_MIN_MSLEEP); + piMinSleep; //cout << "wait" << endl; if (!detached) { wait(&exit_code); diff --git a/libs/main/thread/pigrabberbase.h b/libs/main/thread/pigrabberbase.h index a45d2197..6bb2843b 100644 --- a/libs/main/thread/pigrabberbase.h +++ b/libs/main/thread/pigrabberbase.h @@ -162,7 +162,7 @@ private: return; } if (ret > 0) { - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return; } diag_.received(1); diff --git a/libs/main/thread/pithread.cpp b/libs/main/thread/pithread.cpp index b28b2c34..863d6a63 100644 --- a/libs/main/thread/pithread.cpp +++ b/libs/main/thread/pithread.cpp @@ -402,7 +402,7 @@ bool PIThread::waitForFinish(int timeout_msecs) { if (!running_) return true; if (timeout_msecs < 0) { while (running_) { - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); #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) { - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); #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_) - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return true; } tms_.reset(); while (!running_ && tms_.elapsed_m() < timeout_msecs) - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return tms_.elapsed_m() < timeout_msecs; } diff --git a/libs/main/thread/pitimer.cpp b/libs/main/thread/pitimer.cpp index c94b6c73..83e94885 100644 --- a/libs/main/thread/pitimer.cpp +++ b/libs/main/thread/pitimer.cpp @@ -648,11 +648,11 @@ bool PITimer::stop(bool wait) { bool PITimer::waitForFinish(int timeout_msecs) { if (timeout_msecs < 0) { while (isRunning()) - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return true; } PITimeMeasurer tm; while (isRunning() && tm.elapsed_m() < timeout_msecs) - piMSleep(PIP_MIN_MSLEEP); + piMinSleep(); return tm.elapsed_m() < timeout_msecs; }