doc ru
This commit is contained in:
@@ -28,25 +28,63 @@
|
||||
//! \~russian Класс для простого уведомления и ожидания в различных потоках
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english
|
||||
//!
|
||||
//! \~russian
|
||||
//!
|
||||
//!
|
||||
//! \~english \section PIThreadNotifier_sec0 Synopsis
|
||||
//! \~russian \section PIThreadNotifier_sec0 Краткий обзор
|
||||
//! \~english
|
||||
//! This class used as event mechanism between threads. One thread wait for some event,
|
||||
//! and another send this event, unblocking first thread. It is useful to
|
||||
//! syncronize some actions in several threads.
|
||||
//!
|
||||
//! \~russian
|
||||
//!
|
||||
//!Этот класс используется как событийный механизм между потоками.
|
||||
//! Один поток ждёт некоторого события и другой его отправляет, разблокируя первый.
|
||||
//! Это полезно для синхронизации действий в нескольких потоках.
|
||||
//!
|
||||
//! \~english \section PIThreadNotifier_sec1 Usage
|
||||
//! \~russian \section PIThreadNotifier_sec1 Использование
|
||||
//! \~english
|
||||
//! \~\code
|
||||
//! PIThreadNotifier notifier;
|
||||
//! PITimeMeasurer time;
|
||||
//!
|
||||
//! \~russian
|
||||
//! class Worker: public PIThread {
|
||||
//! PIOBJECT_SUBCLASS(Worker, PIThread)
|
||||
//! public:
|
||||
//! Worker(const PIString & n) {
|
||||
//! setName(n);
|
||||
//! }
|
||||
//! void run() override {
|
||||
//! piCoutObj << (int)time.elapsed_m() << "wait ...";
|
||||
//! notifier.wait();
|
||||
//! piCoutObj << (int)time.elapsed_m() << "done";
|
||||
//! };
|
||||
//! };
|
||||
//!
|
||||
//!
|
||||
//! int main(int argc, char * argv[]) {
|
||||
//! PIVector<Worker*> workers;
|
||||
//!
|
||||
//! // create 2 threads
|
||||
//! for (auto n: {"first ", "second"})
|
||||
//! workers << new Worker(n);
|
||||
//!
|
||||
//! // start them
|
||||
//! for (auto * w: workers)
|
||||
//! w->startOnce();
|
||||
//!
|
||||
//! piMSleep(500);
|
||||
//! notifier.notifyOnce(); // notify one of them after 500 ms
|
||||
//! piMSleep(500);
|
||||
//! notifier.notifyOnce(); // notify one of them after 1000 ms
|
||||
//!
|
||||
//! for (auto * w: workers)
|
||||
//! w->waitForFinish();
|
||||
//! }
|
||||
//!
|
||||
//! // [Worker "first "] 0 wait ...
|
||||
//! // [Worker "second"] 0 wait ...
|
||||
//! // [Worker "second"] 500 done
|
||||
//! // [Worker "first "] 1000 done
|
||||
//! \endcode
|
||||
//! \}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user