PLCnext API Documentation 25.0.2.69
AutoResetEvent.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8
9#include <boost/thread/locks.hpp>
10#include <boost/interprocess/sync/interprocess_mutex.hpp>
11#include <boost/interprocess/sync/interprocess_condition.hpp>
12
13#include <mutex>
14#include <thread>
15#include <memory>
16
17
18namespace Arp { namespace System { namespace Commons { namespace Ipc
19{
20
24{
25public: // typedefs
27 typedef std::shared_ptr<AutoResetEvent> Ptr;
28
29public:
30 explicit AutoResetEvent(bool initial = false);
31 void Set(void);
32 void Reset(void);
33 bool WaitOne(unsigned long timeoutMs = 0);
34
35private: // methods.
36 bool WaitOneInfinite(void);
37 bool TimedWaitOne(unsigned long timeoutMs);
38
39private: // deleted methods
40 AutoResetEvent(const AutoResetEvent&) = delete;
41 AutoResetEvent& operator=(const AutoResetEvent&) = delete;
42
43private: // fields.
44 bool flag;
45 boost::interprocess::interprocess_mutex syncRoot;
46 boost::interprocess::interprocess_condition signal;
47};
48
49}}}} // end of namespace Arp::System::Commons::Threading
Ipc-ready variant of Arp::System::Commons::Threading::AutoResetEvent
Definition: AutoResetEvent.hpp:24
std::shared_ptr< AutoResetEvent > Ptr
Definition of a pointer in the contet of an AutoResetEvent.
Definition: AutoResetEvent.hpp:27
AutoResetEvent(bool initial=false)
Creates a new object with specified initial state.
Definition: AutoResetEvent.cpp:27
void Set(void)
Sets the event to signaled state.
Definition: AutoResetEvent.cpp:34
bool WaitOne(unsigned long timeoutMs=0)
Suspends thread execution until event is signaled by another thread.
Definition: AutoResetEvent.cpp:52
void Reset(void)
Resets the event state to non-signaled.
Definition: AutoResetEvent.cpp:42
Root namespace for the PLCnext API