From db5c4dcf3ffb5e37fa9efd8e7a0231c6a67659d2 Mon Sep 17 00:00:00 2001 From: peri4 Date: Wed, 9 Nov 2022 17:02:28 +0300 Subject: [PATCH] PIThread::stopAndWait --- libs/main/thread/pithread.cpp | 6 ++++++ libs/main/thread/pithread.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/libs/main/thread/pithread.cpp b/libs/main/thread/pithread.cpp index 5b8f372b..7c984c56 100644 --- a/libs/main/thread/pithread.cpp +++ b/libs/main/thread/pithread.cpp @@ -594,6 +594,12 @@ PIThread::~PIThread() { } +void PIThread::stopAndWait(int timeout_ms) { + stop(); + waitForFinish(timeout_ms); +} + + #ifdef WINDOWS NTAPI void winThreadAPC(ULONG_PTR) { //piCout << "APC"; diff --git a/libs/main/thread/pithread.h b/libs/main/thread/pithread.h index 61b90e59..914a29f5 100644 --- a/libs/main/thread/pithread.h +++ b/libs/main/thread/pithread.h @@ -111,6 +111,10 @@ public: EVENT_HANDLER1(void, stop, bool, wait); EVENT_HANDLER0(void, terminate); + //! \~english Stop thread and wait for finish. + //! \~russian Останавливает потоков и ожидает завершения. + void stopAndWait(int timeout_ms = -1); + void interrupt(); //! \~english Set common data passed to external function