|
iceoryx2
C++ Bindings
|
#include <waitset.hpp>
Friends | |
| template<ServiceType> | |
| class | WaitSetBuilder |
The [WaitSet] implements a reactor pattern and allows to wait on multiple events in one single call [WaitSet::wait_and_process_once()] until it wakes up or to run repeatedly with [WaitSet::wait_and_process()] until an 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.
|
delete |
References WaitSet().
Referenced by operator=(), operator=(), WaitSet(), WaitSet(), WaitSetBuilder, and ~WaitSet().
|
noexcept |
References WaitSet().
| iox2::WaitSet< S >::~WaitSet | ( | ) |
References WaitSet().
| 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].
References attach_deadline().
| 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].
References attach_deadline().
Referenced by attach_deadline(), and attach_deadline().
| 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()].
References attach_interval().
Referenced by attach_interval().
| 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.
References attach_notification().
| 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.
References attach_notification().
Referenced by attach_notification(), and attach_notification().
| auto iox2::WaitSet< S >::capacity | ( | ) | const->uint64_t |
| auto iox2::WaitSet< S >::is_empty | ( | ) | const->bool |
Returns true if the [WaitSet] has no attachments, otherwise false.
References is_empty().
Referenced by is_empty().
| auto iox2::WaitSet< S >::len | ( | ) | const->uint64_t |
|
delete |
References WaitSet().
|
noexcept |
References WaitSet().
| auto iox2::WaitSet< S >::signal_handling_mode | ( | ) | const->SignalHandlingMode |
Returns the [SignalHandlingMode] with which the [WaitSet] was created.
References signal_handling_mode().
Referenced by signal_handling_mode().
| auto iox2::WaitSet< S >::wait_and_process | ( | 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]. 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].
Important: The [WaitSet] only reports that an attachment is ready; it does not consume the notification or data that caused the wake-up. If the callback returns without consuming any pending input, the attachment remains ready and the [WaitSet] wakes up again immediately. Repeating this can cause a busy loop and high CPU usage.
For a [Listener], consume pending notifications with [Listener::try_wait()]. For a socket or another file-descriptor-based attachment, consume the pending data using its corresponding read or receive API.
References wait_and_process().
Referenced by wait_and_process().
| 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].
Important: The [WaitSet] only reports that an attachment is ready; it does not consume the notification or data that caused the wake-up. If the callback returns without consuming any pending input, the attachment remains ready and the [WaitSet] wakes up again immediately. Repeating this can cause a busy loop and high CPU usage.
For a [Listener], consume pending notifications with [Listener::try_wait()]. For a socket or another file-descriptor-based attachment, consume the pending data using its corresponding read or receive API.
References wait_and_process_once().
Referenced by wait_and_process_once().
| 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].
Important: The [WaitSet] only reports that an attachment is ready; it does not consume the notification or data that caused the wake-up. If the callback returns without consuming any pending input, the attachment remains ready and the [WaitSet] wakes up again immediately. Repeating this can cause a busy loop and high CPU usage.
For a [Listener], consume pending notifications with [Listener::try_wait()]. For a socket or another file-descriptor-based attachment, consume the pending data using its corresponding read or receive API.
References wait_and_process_once_with_timeout().
Referenced by wait_and_process_once_with_timeout().
Definition at line 284 of file waitset.hpp.
References WaitSet(), and WaitSetBuilder.
Referenced by WaitSetBuilder.