PLCnext API Documentation 25.0.2.69
AutoResetEvent.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Core/PimplPtr.hxx"
9#include "Arp/System/Commons/Threading/Mutex.hpp"
10
12{
13
21{
22public: // usings
24 using Ptr = std::shared_ptr<AutoResetEvent>;
25
26public:
29 explicit AutoResetEvent(bool initial = false);
30
31 // canonical construction/destruction/assignment
32 AutoResetEvent(const AutoResetEvent& arg) = delete;
34 AutoResetEvent& operator=(const AutoResetEvent& arg) = delete;
37
38public: // operations
41 void Set(void);
42
44 void Reset(void);
45
50 bool WaitOne(uint64 timeoutMs = 0);
51
53 void WaitOneInfinite(void);
54
58 bool WaitOneTimed(uint64 timeoutMs);
59
60public: // Impl forward declaration
61 class Impl;
62
63public: // internal operations
64 Impl& GetImpl(void);
65 const Impl& GetImpl(void)const;
66
67private: // Impl usings
68 using Pimpl = PimplPtr<Impl>;
69
70private: // Impl fields
71 Pimpl pimpl;
72};
73
75// inline methods of class AutoResetEvent
76
77} // end of namespace Arp::System::Commons::Threading
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
Event object to signal a single thread that an event has occurred. Can be used to synchronize threads...
Definition: AutoResetEvent.hpp:21
AutoResetEvent & operator=(AutoResetEvent &&arg) noexcept
Default move-assignment operator.
Impl & GetImpl(void)
For internal use only.
Definition: AutoResetEvent.cpp:24
AutoResetEvent(bool initial=false)
Creates a new object with specified initial state.
Definition: AutoResetEvent.cpp:9
AutoResetEvent(AutoResetEvent &&arg) noexcept
Default move constructor.
bool WaitOne(uint64 timeoutMs=0)
Suspends thread execution until event is signaled by another thread.
Definition: AutoResetEvent.cpp:35
void Set(void)
Sets the event to signaled state.
Definition: AutoResetEvent.cpp:50
bool WaitOneTimed(uint64 timeoutMs)
Suspends thread execution until event is signaled by another thread.
Definition: AutoResetEvent.cpp:45
void WaitOneInfinite(void)
Suspends thread execution until event is signaled by another thread.
Definition: AutoResetEvent.cpp:40
void Reset(void)
Resets the event state to non-signaled.
Definition: AutoResetEvent.cpp:55
std::shared_ptr< AutoResetEvent > Ptr
Definition of a pointer in the context of an AutoResetEvent.
Definition: AutoResetEvent.hpp:24
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:37
Namespace for classes handling threads and synchronization