|
iceoryx2
C++ Language Bindings
|
#include <waitset.hpp>
Friends | |
| class | WaitSetBuilder |
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.
|
delete |
|
noexcept |
| iox2::WaitSet< S >::~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].
FileDescriptor] must life at least as long as the returned [WaitSetGuard].WaitSetGuard] must life at least as long as the [WaitsSet]. | 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].
Listener] must life at least as long as the returned [WaitSetGuard].WaitSetGuard] must life at least as long as the [WaitsSet]. | 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()].
WaitSetGuard] must life at least as long as the [WaitsSet]. | 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.
FileDescriptor] must life at least as long as the returned [WaitSetGuard].WaitSetGuard] must life at least as long as the [WaitsSet]. | 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.
Listener] must life at least as long as the returned [WaitSetGuard].WaitSetGuard] must life at least as long as the [WaitsSet]. | auto iox2::WaitSet< S >::capacity | ( | ) | const -> uint64_t |
Returns the capacity of the [WaitSet].
| auto iox2::WaitSet< S >::is_empty | ( | ) | const -> bool |
Returns true if the [WaitSet] has no attachments, otherwise false.
| auto iox2::WaitSet< S >::len | ( | ) | const -> uint64_t |
Returns the number of attachments.
|
delete |
|
noexcept |
| auto iox2::WaitSet< S >::signal_handling_mode | ( | ) | const -> SignalHandlingMode |
Returns the [SignalHandlingMode] with which the [WaitSet] was created.
| 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].
| 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].
| 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].
|
friend |
Definition at line 250 of file waitset.hpp.