PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | List of all members
Arp::System::Commons::Threading::AutoResetEvent Class Reference

Event object to signal a single thread that an event has occurred. Can be used to synchronize threads in different processes. More...

#include <AutoResetEvent.hpp>

Public Types

using Ptr = std::shared_ptr< AutoResetEvent >
 Definition of a pointer in the context of an AutoResetEvent.
 

Public Member Functions

 AutoResetEvent (bool initial=false)
 Creates a new object with specified initial state. More...
 
 AutoResetEvent (const AutoResetEvent &arg)=delete
 
 AutoResetEvent (AutoResetEvent &&arg) noexcept
 Default move constructor.
 
AutoResetEventoperator= (const AutoResetEvent &arg)=delete
 
AutoResetEventoperator= (AutoResetEvent &&arg) noexcept
 Default move-assignment operator.
 
 ~AutoResetEvent ()
 Default destructor.
 
void Set (void)
 Sets the event to signaled state. More...
 
void Reset (void)
 Resets the event state to non-signaled.
 
bool WaitOne (uint64 timeoutMs=0)
 Suspends thread execution until event is signaled by another thread. More...
 
void WaitOneInfinite (void)
 Suspends thread execution until event is signaled by another thread.
 
bool WaitOneTimed (uint64 timeoutMs)
 Suspends thread execution until event is signaled by another thread. More...
 
Impl & GetImpl (void)
 For internal use only.
 
const Impl & GetImpl (void) const
 

Detailed Description

Event object to signal a single thread that an event has occurred. Can be used to synchronize threads in different processes.

Auto-reset events can be used to signal a single thread about the occurrence of a specific events. The thread to be informed has to call WaitOne() and then blocks until another thread calls Set to inform the waiter about the event occurrence. Once the waiting thread was waken up, the instance of the event automatically resets its internal state to non-signaled so that a succeeding call to WaitOne() will cause the calling thread to block again.

Constructor & Destructor Documentation

◆ AutoResetEvent()

Arp::System::Commons::Threading::AutoResetEvent::AutoResetEvent ( bool  initial = false)
explicit

Creates a new object with specified initial state.

Parameters
initialInitial state of event.

Member Function Documentation

◆ Set()

void Arp::System::Commons::Threading::AutoResetEvent::Set ( void  )

Sets the event to signaled state.

Causes a thread waiting on this event to resume its execution.

◆ WaitOne()

bool Arp::System::Commons::Threading::AutoResetEvent::WaitOne ( uint64  timeoutMs = 0)

Suspends thread execution until event is signaled by another thread.

Parameters
timeoutMsTimeout in milliseconds to wait for the event to become signaled. If the value is set to 0 (default) the calling thread will wait infinitly or until the event is set.
Returns
Returns false if the timeout was reached before the event was signaled, otherwise true is returned.

◆ WaitOneTimed()

bool Arp::System::Commons::Threading::AutoResetEvent::WaitOneTimed ( uint64  timeoutMs)

Suspends thread execution until event is signaled by another thread.

Parameters
timeoutMsTimeout in milliseconds to wait for the event to become signaled.
Returns
Returns false if the timeout was reached before the event was signaled, otherwise true is returned.

The documentation for this class was generated from the following files: