iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
iox2::WaitSet< S > Class Template Reference

#include <waitset.hpp>

Public Member Functions

 WaitSet (const WaitSet &)=delete
 
auto operator= (const WaitSet &) -> WaitSet &=delete
 
 WaitSet (WaitSet &&) noexcept
 
auto operator= (WaitSet &&) noexcept -> WaitSet &
 
 ~WaitSet ()
 
auto wait_and_process (const iox2::bb::StaticFunction< CallbackProgression(WaitSetAttachmentId< S >)> &fn_call) -> bb::Expected< WaitSetRunResult, WaitSetRunError >
 
auto wait_and_process_once (const iox2::bb::StaticFunction< CallbackProgression(WaitSetAttachmentId< S >)> &fn_call) -> bb::Expected< WaitSetRunResult, WaitSetRunError >
 
auto wait_and_process_once_with_timeout (const iox2::bb::StaticFunction< CallbackProgression(WaitSetAttachmentId< S >)> &fn_call, iox2::bb::Duration timeout) -> bb::Expected< WaitSetRunResult, WaitSetRunError >
 
auto capacity () const -> uint64_t
 Returns the capacity of the [WaitSet].
 
auto len () const -> uint64_t
 Returns the number of attachments.
 
auto is_empty () const -> bool
 Returns true if the [WaitSet] has no attachments, otherwise false.
 
auto attach_notification (const Listener< S > &listener) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >
 
auto attach_notification (const FileDescriptorBased &attachment) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >
 
auto attach_deadline (const Listener< S > &listener, iox2::bb::Duration deadline) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >
 
auto attach_deadline (const FileDescriptorBased &attachment, iox2::bb::Duration deadline) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >
 
auto attach_interval (iox2::bb::Duration deadline) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >
 
auto signal_handling_mode () const -> SignalHandlingMode
 Returns the [SignalHandlingMode] with which the [WaitSet] was created.
 

Friends

class WaitSetBuilder
 

Detailed Description

template<ServiceType S>
class iox2::WaitSet< S >

The [WaitSet] implements a reactor pattern and allows to wait on multiple events in one single call [WaitSet::try_wait_and_process()] until it wakes up or to run repeatedly with [WaitSet::wait_and_process()] until the a interrupt or termination signal was received or the user has explicitly requested to stop by returning [CallbackProgression::Stop] in the provided callback.

The [Listener] can be attached as well as sockets or anything else that can be packed into a [FileDescriptorView].

Can be created via the [WaitSetBuilder].

Definition at line 117 of file waitset.hpp.

Constructor & Destructor Documentation

◆ WaitSet() [1/2]

template<ServiceType S>
iox2::WaitSet< S >::WaitSet ( const WaitSet< S > &  )
delete

◆ WaitSet() [2/2]

template<ServiceType S>
iox2::WaitSet< S >::WaitSet ( WaitSet< S > &&  )
noexcept

◆ ~WaitSet()

template<ServiceType S>
iox2::WaitSet< S >::~WaitSet ( )

Member Function Documentation

◆ attach_deadline() [1/2]

template<ServiceType S>
auto iox2::WaitSet< S >::attach_deadline ( const FileDescriptorBased attachment,
iox2::bb::Duration  deadline 
) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >

Attaches a [FileDescriptorBased] object as deadline to the [WaitSet]. Whenever the event is received or the deadline is hit, the user is informed in [WaitSet::wait_and_process()]. The object cannot be attached twice and the [WaitSet::capacity()] is limited by the underlying implementation. Whenever the object emits an event the deadline is reset by the [WaitSet].

Safety

◆ attach_deadline() [2/2]

template<ServiceType S>
auto iox2::WaitSet< S >::attach_deadline ( const Listener< S > &  listener,
iox2::bb::Duration  deadline 
) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >

Attaches a [Listener] as deadline to the [WaitSet]. Whenever the event is received or the deadline is hit, the user is informed in [WaitSet::wait_and_process()]. The object cannot be attached twice and the [WaitSet::capacity()] is limited by the underlying implementation. Whenever the object emits an event the deadline is reset by the [WaitSet].

Safety

◆ attach_interval()

template<ServiceType S>
auto iox2::WaitSet< S >::attach_interval ( iox2::bb::Duration  deadline) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >

Attaches a tick event to the [WaitSet]. Whenever the timeout is reached the [WaitSet] informs the user in [WaitSet::wait_and_process()].

Safety

  • The [WaitSetGuard] must life at least as long as the [WaitsSet].

◆ attach_notification() [1/2]

template<ServiceType S>
auto iox2::WaitSet< S >::attach_notification ( const FileDescriptorBased attachment) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >

Attaches a [FileDescriptorBased] object as notification to the [WaitSet]. Whenever an event is received on the object the [WaitSet] informs the user in [WaitSet::wait_and_process()] to handle the event. The object cannot be attached twice and the [WaitSet::capacity()] is limited by the underlying implementation.

Safety

◆ attach_notification() [2/2]

template<ServiceType S>
auto iox2::WaitSet< S >::attach_notification ( const Listener< S > &  listener) -> bb::Expected< WaitSetGuard< S >, WaitSetAttachmentError >

Attaches a [Listener] as notification to the [WaitSet]. Whenever an event is received on the object the [WaitSet] informs the user in [WaitSet::wait_and_process()] to handle the event. The object cannot be attached twice and the [WaitSet::capacity()] is limited by the underlying implementation.

Safety

◆ capacity()

template<ServiceType S>
auto iox2::WaitSet< S >::capacity ( ) const -> uint64_t

Returns the capacity of the [WaitSet].

◆ is_empty()

template<ServiceType S>
auto iox2::WaitSet< S >::is_empty ( ) const -> bool

Returns true if the [WaitSet] has no attachments, otherwise false.

◆ len()

template<ServiceType S>
auto iox2::WaitSet< S >::len ( ) const -> uint64_t

Returns the number of attachments.

◆ operator=() [1/2]

template<ServiceType S>
auto iox2::WaitSet< S >::operator= ( const WaitSet< S > &  ) -> WaitSet &=delete
delete

◆ operator=() [2/2]

template<ServiceType S>
auto iox2::WaitSet< S >::operator= ( WaitSet< S > &&  ) -> WaitSet &
noexcept

◆ signal_handling_mode()

template<ServiceType S>
auto iox2::WaitSet< S >::signal_handling_mode ( ) const -> SignalHandlingMode

Returns the [SignalHandlingMode] with which the [WaitSet] was created.

◆ wait_and_process()

Waits until an event arrives on the [WaitSet], then collects all events by calling the provided fn_call callback with the corresponding [WaitSetAttachmentId]. In contrast to [WaitSet::wait_and_process_once()] it will never return until the user explicitly requests it by returning [CallbackProgression::Stop] or by receiving a signal.

The provided callback must return [CallbackProgression::Continue] to continue the event processing and handle the next event or [CallbackProgression::Stop] to return from this call immediately. All unhandled events will be lost forever and the call will return [WaitSetRunResult::StopRequest].

If an interrupt- (SIGINT) or a termination-signal (SIGTERM) was received, it will exit the loop and inform the user with [WaitSetRunResult::Interrupt] or [WaitSetRunResult::TerminationRequest].

◆ wait_and_process_once()

template<ServiceType S>
auto iox2::WaitSet< S >::wait_and_process_once ( const iox2::bb::StaticFunction< CallbackProgression(WaitSetAttachmentId< S >)> &  fn_call) -> bb::Expected< WaitSetRunResult, WaitSetRunError >

Waits until an event arrives on the [WaitSet], then collects all events by calling the provided fn_call callback with the corresponding [WaitSetAttachmentId] and then returns. This makes it ideal to be called in some kind of event-loop.

The provided callback must return [CallbackProgression::Continue] to continue the event processing and handle the next event or [CallbackProgression::Stop] to return from this call immediately. All unhandled events will be lost forever and the call will return [WaitSetRunResult::StopRequest].

If an interrupt- (SIGINT) or a termination-signal (SIGTERM) was received, it will exit the loop and inform the user with [WaitSetRunResult::Interrupt] or [WaitSetRunResult::TerminationRequest].

When no signal was received and all events were handled, it will return [WaitSetRunResult::AllEventsHandled].

◆ wait_and_process_once_with_timeout()

template<ServiceType S>
auto iox2::WaitSet< S >::wait_and_process_once_with_timeout ( const iox2::bb::StaticFunction< CallbackProgression(WaitSetAttachmentId< S >)> &  fn_call,
iox2::bb::Duration  timeout 
) -> bb::Expected< WaitSetRunResult, WaitSetRunError >

Waits until an event arrives on the [WaitSet] or the provided timeout has passed, then collects all events by calling the provided fn_call callback with the corresponding [WaitSetAttachmentId] and then returns. This makes it ideal to be called in some kind of event-loop.

The provided callback must return [CallbackProgression::Continue] to continue the event processing and handle the next event or [CallbackProgression::Stop] to return from this call immediately. All unhandled events will be lost forever and the call will return [WaitSetRunResult::StopRequest].

If an interrupt- (SIGINT) or a termination-signal (SIGTERM) was received, it will exit the loop and inform the user with [WaitSetRunResult::Interrupt] or [WaitSetRunResult::TerminationRequest].

When no signal was received and all events were handled, it will return [WaitSetRunResult::AllEventsHandled].

Friends And Related Symbol Documentation

◆ WaitSetBuilder

template<ServiceType S>
friend class WaitSetBuilder
friend

Definition at line 250 of file waitset.hpp.


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