version 3.21.0

add PISystemTime overload for thread/timer/io classes
This commit is contained in:
2024-07-09 16:32:27 +03:00
parent 9cd05996e7
commit 903b320629
9 changed files with 172 additions and 130 deletions

View File

@@ -104,22 +104,16 @@ public:
};
EVENT_HANDLER0(bool, start) { return start(-1); }
EVENT_HANDLER1(bool, start, int, timer_delay);
EVENT_HANDLER1(bool, start, int, loop_delay);
bool start(PISystemTime loop_delay) { return start(loop_delay.toMilliseconds()); }
bool start(ThreadFunc func) { return start(func, -1); }
bool start(ThreadFunc func, int timer_delay) {
ret_func = func;
return start(timer_delay);
}
bool start(ThreadFunc func, int loop_delay);
bool start(ThreadFunc func, PISystemTime loop_delay) { return start(func, loop_delay.toMilliseconds()); }
bool start(std::function<void()> func) { return start(func, -1); }
bool start(std::function<void()> func, int timer_delay) {
ret_func = [func](void *) { func(); };
return start(timer_delay);
}
bool start(std::function<void()> func, int loop_delay);
bool start(std::function<void()> func, PISystemTime loop_delay) { return start(func, loop_delay.toMilliseconds()); }
EVENT_HANDLER0(bool, startOnce);
EVENT_HANDLER1(bool, startOnce, ThreadFunc, func) {
ret_func = func;
return startOnce();
}
EVENT_HANDLER1(bool, startOnce, ThreadFunc, func);
EVENT_HANDLER0(void, stop);
EVENT_HANDLER0(void, terminate);
@@ -127,6 +121,10 @@ public:
//! \~russian Останавливает поток и ожидает завершения.
void stopAndWait(int timeout_ms = -1);
//! \~english Stop thread and wait for finish.
//! \~russian Останавливает поток и ожидает завершения.
void stopAndWait(PISystemTime timeout) { stopAndWait(timeout.toMilliseconds()); }
//! \~english Set common data passed to external function
//! \~russian Устанавливает данные, передаваемые в функцию потока
void setData(void * d) { data_ = d; }
@@ -200,7 +198,7 @@ public:
//! \handlers
//! \{
//! \fn bool start(int timer_delay = -1)
//! \fn bool start(int loop_delay = -1)
//! \brief
//! \~english Start thread
//! \~russian Запускает поток
@@ -268,8 +266,8 @@ protected:
//! \~russian Метод выполняется один раз при старте потока
virtual void begin() { ; }
//! \~english Function executed at every "timer_delay" msecs until thread was stopped
//! \~russian Метод выполняется каждые "timer_delay" миллисекунд
//! \~english Function executed at every "loop_delay" msecs until thread was stopped
//! \~russian Метод выполняется каждые "loop_delay" миллисекунд
virtual void run() { ; }
//! \~english Function executed once at the end of thread
@@ -278,12 +276,12 @@ protected:
std::atomic_bool terminating, running_, lockRun;
int delay_, policy_;
llong tid_;
void * data_;
llong tid_ = -1;
void * data_ = nullptr;
mutable PIMutex thread_mutex;
PITimeMeasurer tmf_, tms_, tmr_;
PIThread::Priority priority_;
ThreadFunc ret_func;
PIThread::Priority priority_ = piNormal;
ThreadFunc ret_func = nullptr;
PRIVATE_DECLARATION(PIP_EXPORT)
private: