Skip to content

Commit ce791a4

Browse files
committed
[#390] Rename wait_and_process_events into wait_and_process
1 parent 9db6181 commit ce791a4

File tree

8 files changed

+74
-77
lines changed

8 files changed

+74
-77
lines changed

examples/rust/event_multiplexing/wait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6868
// loops until the user has pressed CTRL+c, the application has received a SIGTERM or SIGINT
6969
// signal or the user has called explicitly `waitset.stop()` in the `on_event` callback. We
7070
// didn't add this to the example so feel free to play around with it.
71-
waitset.wait_and_process_events(on_event)?;
71+
waitset.wait_and_process(on_event)?;
7272

7373
println!("Exit");
7474

iceoryx2-ffi/cxx/include/iox2/waitset.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
namespace iox2 {
2525
/// The [`WaitSetGuard`] is returned by [`WaitSet::attach_deadline()`], [`WaitSet::attach_notification()`]
2626
/// or [`WaitSet::attach_interval()`]. As soon as it goes out-of-scope it detaches the attachment.
27-
/// It can also be used to determine the origin of an event in [`WaitSet::wait_and_process_events()`] or
28-
/// [`WaitSet::try_wait_and_process_events()`] via [`WaitSetAttachmentId::has_event_from()`] or
27+
/// It can also be used to determine the origin of an event in [`WaitSet::wait_and_process()`] or
28+
/// [`WaitSet::try_wait_and_process()`] via [`WaitSetAttachmentId::has_event_from()`] or
2929
/// [`WaitSetAttachmentId::has_missed_deadline()`].
3030
template <ServiceType S>
3131
class WaitSetGuard {
@@ -93,8 +93,8 @@ template <ServiceType S>
9393
auto operator<(const WaitSetAttachmentId<S>& lhs, const WaitSetAttachmentId<S>& rhs) -> bool;
9494

9595
/// The [`WaitSet`] implements a reactor pattern and allows to wait on multiple events in one
96-
/// single call [`WaitSet::try_wait_and_process_events()`] until it wakes up or to run repeatedly with
97-
/// [`WaitSet::wait_and_process_events()`] until the a interrupt or termination signal was received or the user
96+
/// single call [`WaitSet::try_wait_and_process()`] until it wakes up or to run repeatedly with
97+
/// [`WaitSet::wait_and_process()`] until the a interrupt or termination signal was received or the user
9898
/// has explicitly requested to stop with [`WaitSet::stop()`].
9999
///
100100
/// The [`Listener`] can be attached as well as sockets or anything else that
@@ -110,7 +110,7 @@ class WaitSet {
110110
auto operator=(WaitSet&&) noexcept -> WaitSet&;
111111
~WaitSet();
112112

113-
/// Can be called from within a callback during [`WaitSet::wait_and_process_events()`] to signal the [`WaitSet`]
113+
/// Can be called from within a callback during [`WaitSet::wait_and_process()`] to signal the [`WaitSet`]
114114
/// to stop running after this iteration.
115115
void stop();
116116

@@ -119,14 +119,14 @@ class WaitSet {
119119
/// acquire the source.
120120
/// If an interrupt- (`SIGINT`) or a termination-signal (`SIGTERM`) was received, it will exit
121121
/// the loop and inform the user via [`WaitSetRunResult`].
122-
auto wait_and_process_events(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
122+
auto wait_and_process(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
123123
-> iox::expected<WaitSetRunResult, WaitSetRunError>;
124124

125125
/// Tries to wait on the [`WaitSet`]. The provided callback is called for every attachment that
126126
/// was triggered and the [`WaitSetAttachmentId`] is provided as an input argument to acquire the
127127
/// source.
128128
/// If nothing was triggered the [`WaitSet`] returns immediately.
129-
auto try_wait_and_process_events(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
129+
auto try_wait_and_process(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
130130
-> iox::expected<void, WaitSetRunError>;
131131

132132
/// Returns the capacity of the [`WaitSet`]
@@ -139,7 +139,7 @@ class WaitSet {
139139
auto is_empty() const -> bool;
140140

141141
/// Attaches a [`Listener`] as notification to the [`WaitSet`]. Whenever an event is received on the
142-
/// object the [`WaitSet`] informs the user in [`WaitSet::wait_and_process_events()`] to handle the event.
142+
/// object the [`WaitSet`] informs the user in [`WaitSet::wait_and_process()`] to handle the event.
143143
/// The object cannot be attached twice and the
144144
/// [`WaitSet::capacity()`] is limited by the underlying implementation.
145145
///
@@ -150,7 +150,7 @@ class WaitSet {
150150
auto attach_notification(const Listener<S>& listener) -> iox::expected<WaitSetGuard<S>, WaitSetAttachmentError>;
151151

152152
/// Attaches a [`FileDescriptorView`] as notification to the [`WaitSet`]. Whenever an event is received on the
153-
/// object the [`WaitSet`] informs the user in [`WaitSet::wait_and_process_events()`] to handle the event.
153+
/// object the [`WaitSet`] informs the user in [`WaitSet::wait_and_process()`] to handle the event.
154154
/// The object cannot be attached twice and the
155155
/// [`WaitSet::capacity()`] is limited by the underlying implementation.
156156
///
@@ -162,7 +162,7 @@ class WaitSet {
162162
attach_notification(FileDescriptorView file_descriptor) -> iox::expected<WaitSetGuard<S>, WaitSetAttachmentError>;
163163

164164
/// Attaches a [`Listener`] as deadline to the [`WaitSet`]. Whenever the event is received or the
165-
/// deadline is hit, the user is informed in [`WaitSet::wait_and_process_events()`].
165+
/// deadline is hit, the user is informed in [`WaitSet::wait_and_process()`].
166166
/// The object cannot be attached twice and the
167167
/// [`WaitSet::capacity()`] is limited by the underlying implementation.
168168
/// Whenever the object emits an event the deadline is reset by the [`WaitSet`].
@@ -175,7 +175,7 @@ class WaitSet {
175175
iox::units::Duration deadline) -> iox::expected<WaitSetGuard<S>, WaitSetAttachmentError>;
176176

177177
/// Attaches a [`FileDescriptorView`] as deadline to the [`WaitSet`]. Whenever the event is received or the
178-
/// deadline is hit, the user is informed in [`WaitSet::wait_and_process_events()`].
178+
/// deadline is hit, the user is informed in [`WaitSet::wait_and_process()`].
179179
/// The object cannot be attached twice and the
180180
/// [`WaitSet::capacity()`] is limited by the underlying implementation.
181181
/// Whenever the object emits an event the deadline is reset by the [`WaitSet`].
@@ -188,7 +188,7 @@ class WaitSet {
188188
iox::units::Duration deadline) -> iox::expected<WaitSetGuard<S>, WaitSetAttachmentError>;
189189

190190
/// Attaches a tick event to the [`WaitSet`]. Whenever the timeout is reached the [`WaitSet`]
191-
/// informs the user in [`WaitSet::wait_and_process_events()`].
191+
/// informs the user in [`WaitSet::wait_and_process()`].
192192
///
193193
/// # Safety
194194
///

iceoryx2-ffi/cxx/src/waitset.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,11 @@ auto run_callback(iox2_waitset_attachment_id_h attachment_id, void* context) {
280280
}
281281

282282
template <ServiceType S>
283-
auto WaitSet<S>::wait_and_process_events(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
283+
auto WaitSet<S>::wait_and_process(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
284284
-> iox::expected<WaitSetRunResult, WaitSetRunError> {
285285
iox2_waitset_run_result_e run_result = iox2_waitset_run_result_e_STOP_REQUEST;
286286
auto ctx = internal::ctx(fn_call);
287-
auto result =
288-
iox2_waitset_wait_and_process_events(&m_handle, run_callback<S>, static_cast<void*>(&ctx), &run_result);
287+
auto result = iox2_waitset_wait_and_process(&m_handle, run_callback<S>, static_cast<void*>(&ctx), &run_result);
289288

290289
if (result == IOX2_OK) {
291290
return iox::ok(iox::into<WaitSetRunResult>(static_cast<int>(run_result)));
@@ -295,10 +294,10 @@ auto WaitSet<S>::wait_and_process_events(const iox::function<void(WaitSetAttachm
295294
}
296295

297296
template <ServiceType S>
298-
auto WaitSet<S>::try_wait_and_process_events(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
297+
auto WaitSet<S>::try_wait_and_process(const iox::function<void(WaitSetAttachmentId<S>)>& fn_call)
299298
-> iox::expected<void, WaitSetRunError> {
300299
auto ctx = internal::ctx(fn_call);
301-
auto result = iox2_waitset_try_wait_and_process_events(&m_handle, run_callback<S>, static_cast<void*>(&ctx));
300+
auto result = iox2_waitset_try_wait_and_process(&m_handle, run_callback<S>, static_cast<void*>(&ctx));
302301

303302
if (result == IOX2_OK) {
304303
return iox::ok();

iceoryx2-ffi/cxx/tests/src/waitset_tests.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ TYPED_TEST(WaitSetTest, attaching_same_notification_twice_fails) {
132132

133133
TYPED_TEST(WaitSetTest, empty_waitset_returns_error_on_run) {
134134
auto sut = this->create_sut();
135-
auto result = sut.wait_and_process_events([](auto) {});
135+
auto result = sut.wait_and_process([](auto) {});
136136

137137
ASSERT_THAT(result.has_error(), Eq(true));
138138
ASSERT_THAT(result.get_error(), Eq(WaitSetRunError::NoAttachments));
139139
}
140140

141141
TYPED_TEST(WaitSetTest, empty_waitset_returns_error_on_run_once) {
142142
auto sut = this->create_sut();
143-
auto result = sut.try_wait_and_process_events([](auto) {});
143+
auto result = sut.try_wait_and_process([](auto) {});
144144

145145
ASSERT_THAT(result.has_error(), Eq(true));
146146
ASSERT_THAT(result.get_error(), Eq(WaitSetRunError::NoAttachments));
@@ -153,7 +153,7 @@ TYPED_TEST(WaitSetTest, interval_attachment_blocks_for_at_least_timeout) {
153153
auto guard = sut.attach_interval(TIMEOUT).expect("");
154154

155155
auto callback_called = false;
156-
auto result = sut.wait_and_process_events([&](auto attachment_id) {
156+
auto result = sut.wait_and_process([&](auto attachment_id) {
157157
callback_called = true;
158158
sut.stop();
159159
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
@@ -175,7 +175,7 @@ TYPED_TEST(WaitSetTest, deadline_attachment_blocks_for_at_least_timeout) {
175175
auto guard = sut.attach_deadline(listener, TIMEOUT).expect("");
176176

177177
auto callback_called = false;
178-
auto result = sut.wait_and_process_events([&](auto attachment_id) {
178+
auto result = sut.wait_and_process([&](auto attachment_id) {
179179
callback_called = true;
180180
sut.stop();
181181
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(false));
@@ -201,7 +201,7 @@ TYPED_TEST(WaitSetTest, deadline_attachment_wakes_up_when_notified) {
201201
auto notifier = this->create_notifier();
202202
notifier.notify().expect("");
203203
});
204-
auto result = sut.wait_and_process_events([&](auto attachment_id) {
204+
auto result = sut.wait_and_process([&](auto attachment_id) {
205205
callback_called = true;
206206
sut.stop();
207207
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
@@ -224,7 +224,7 @@ TYPED_TEST(WaitSetTest, notification_attachment_wakes_up_when_notified) {
224224
auto notifier = this->create_notifier();
225225
notifier.notify().expect("");
226226
});
227-
auto result = sut.wait_and_process_events([&](auto attachment_id) {
227+
auto result = sut.wait_and_process([&](auto attachment_id) {
228228
callback_called = true;
229229
sut.stop();
230230
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
@@ -266,7 +266,7 @@ TYPED_TEST(WaitSetTest, triggering_everything_works) {
266266
std::this_thread::sleep_for(std::chrono::milliseconds(TIMEOUT.toMilliseconds()));
267267
std::vector<bool> was_triggered(guards.size(), false);
268268

269-
sut.try_wait_and_process_events([&](auto attachment_id) {
269+
sut.try_wait_and_process([&](auto attachment_id) {
270270
for (uint64_t idx = 0; idx < guards.size(); ++idx) {
271271
if (attachment_id.has_event_from(guards[idx])) {
272272
was_triggered[idx] = true;

iceoryx2-ffi/ffi/src/api/waitset.rs

+23-25
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub unsafe extern "C" fn iox2_waitset_capacity(handle: iox2_waitset_h_ref) -> c_
283283
}
284284
}
285285

286-
/// Stops the current [`iox2_waitset_wait_and_process_events()`] operation. Any [`iox2_waitset_wait_and_process_events()`]
286+
/// Stops the current [`iox2_waitset_wait_and_process()`] operation. Any [`iox2_waitset_wait_and_process()`]
287287
/// call after this call is not affected and the user needs to call
288288
/// [`iox2_waitset_stop()`] again.
289289
///
@@ -305,7 +305,7 @@ pub unsafe extern "C" fn iox2_waitset_stop(handle: iox2_waitset_h_ref) {
305305

306306
/// Attaches a provided [`iox2_file_descriptor_ptr`] as notification to the
307307
/// [`iox2_waitset_h`]. As soon as the attachment receives data, the WaitSet
308-
/// wakes up in [`iox2_waitset_wait_and_process_events()`] and informs the user.
308+
/// wakes up in [`iox2_waitset_wait_and_process()`] and informs the user.
309309
///
310310
/// With [`iox2_waitset_attachment_id_has_event_from()`](crate::iox2_waitset_attachment_id_has_event_from())
311311
/// the origin of the event can be determined from its corresponding
@@ -381,7 +381,7 @@ pub unsafe extern "C" fn iox2_waitset_attach_notification(
381381

382382
/// Attaches a provided [`iox2_file_descriptor_ptr`] as deadline to the
383383
/// [`iox2_waitset_h`]. As soon as the attachment receives data or the deadline
384-
/// was missed, the WaitSet wakes up in [`iox2_waitset_wait_and_process_events()`] and informs the user.
384+
/// was missed, the WaitSet wakes up in [`iox2_waitset_wait_and_process()`] and informs the user.
385385
///
386386
/// With [`iox2_waitset_attachment_id_has_event_from()`](crate::iox2_waitset_attachment_id_has_event_from())
387387
/// the origin of the event can be determined from its corresponding
@@ -469,7 +469,7 @@ pub unsafe extern "C" fn iox2_waitset_attach_deadline(
469469
}
470470

471471
/// Attaches an interval to the [`iox2_waitset_h`]. As soon as the interval has passed
472-
/// the WaitSet wakes up in [`iox2_waitset_wait_and_process_events()`] and informs the user.
472+
/// the WaitSet wakes up in [`iox2_waitset_wait_and_process()`] and informs the user.
473473
///
474474
/// With [`iox2_waitset_attachment_id_has_event_from()`](crate::iox2_waitset_attachment_id_has_event_from())
475475
/// the origin of the event can be determined from its corresponding
@@ -568,7 +568,7 @@ pub unsafe extern "C" fn iox2_waitset_attach_interval(
568568
/// * the provided [`iox2_waitset_attachment_id_h`] in the callback must be released via
569569
/// [`iox2_waitset_attachment_id_drop()`](crate::iox2_waitset_attachment_id_drop())
570570
#[no_mangle]
571-
pub unsafe extern "C" fn iox2_waitset_try_wait_and_process_events(
571+
pub unsafe extern "C" fn iox2_waitset_try_wait_and_process(
572572
handle: iox2_waitset_h_ref,
573573
callback: iox2_waitset_run_callback,
574574
callback_ctx: iox2_callback_context,
@@ -583,7 +583,7 @@ pub unsafe extern "C" fn iox2_waitset_try_wait_and_process_events(
583583
.value
584584
.as_ref()
585585
.ipc
586-
.try_wait_and_process_events(|attachment_id| {
586+
.try_wait_and_process(|attachment_id| {
587587
let attachment_id_ptr = iox2_waitset_attachment_id_t::alloc();
588588
(*attachment_id_ptr).init(
589589
waitset.service_type,
@@ -599,7 +599,7 @@ pub unsafe extern "C" fn iox2_waitset_try_wait_and_process_events(
599599
.value
600600
.as_ref()
601601
.local
602-
.try_wait_and_process_events(|attachment_id| {
602+
.try_wait_and_process(|attachment_id| {
603603
let attachment_id_ptr = iox2_waitset_attachment_id_t::alloc();
604604
(*attachment_id_ptr).init(
605605
waitset.service_type,
@@ -643,7 +643,7 @@ pub unsafe extern "C" fn iox2_waitset_try_wait_and_process_events(
643643
/// * the provided [`iox2_waitset_attachment_id_h`] in the callback must be released via
644644
/// [`iox2_waitset_attachment_id_drop()`](crate::iox2_waitset_attachment_id_drop())
645645
#[no_mangle]
646-
pub unsafe extern "C" fn iox2_waitset_wait_and_process_events(
646+
pub unsafe extern "C" fn iox2_waitset_wait_and_process(
647647
handle: iox2_waitset_h_ref,
648648
callback: iox2_waitset_run_callback,
649649
callback_ctx: iox2_callback_context,
@@ -655,28 +655,26 @@ pub unsafe extern "C" fn iox2_waitset_wait_and_process_events(
655655
let waitset = &mut *handle.as_type();
656656

657657
let run_result = match waitset.service_type {
658-
iox2_service_type_e::IPC => {
659-
waitset
660-
.value
661-
.as_ref()
662-
.ipc
663-
.wait_and_process_events(|attachment_id| {
664-
let attachment_id_ptr = iox2_waitset_attachment_id_t::alloc();
665-
(*attachment_id_ptr).init(
666-
waitset.service_type,
667-
AttachmentIdUnion::new_ipc(attachment_id),
668-
iox2_waitset_attachment_id_t::dealloc,
669-
);
670-
let attachment_id_handle_ptr = (*attachment_id_ptr).as_handle();
671-
callback(attachment_id_handle_ptr, callback_ctx);
672-
})
673-
}
658+
iox2_service_type_e::IPC => waitset
659+
.value
660+
.as_ref()
661+
.ipc
662+
.wait_and_process(|attachment_id| {
663+
let attachment_id_ptr = iox2_waitset_attachment_id_t::alloc();
664+
(*attachment_id_ptr).init(
665+
waitset.service_type,
666+
AttachmentIdUnion::new_ipc(attachment_id),
667+
iox2_waitset_attachment_id_t::dealloc,
668+
);
669+
let attachment_id_handle_ptr = (*attachment_id_ptr).as_handle();
670+
callback(attachment_id_handle_ptr, callback_ctx);
671+
}),
674672
iox2_service_type_e::LOCAL => {
675673
waitset
676674
.value
677675
.as_ref()
678676
.local
679-
.wait_and_process_events(|attachment_id| {
677+
.wait_and_process(|attachment_id| {
680678
let attachment_id_ptr = iox2_waitset_attachment_id_t::alloc();
681679
(*attachment_id_ptr).init(
682680
waitset.service_type,

iceoryx2-ffi/ffi/src/api/waitset_attachment_id.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl HandleToType for iox2_waitset_attachment_id_h_ref {
112112

113113
// BEGIN C API
114114
/// Release an [`iox2_waitset_attachment_id_h`] that was acquired by calling either
115-
/// * [`iox2_waitset_wait_and_process_events()`](crate::iox2_waitset_wait_and_process_events())
116-
/// * [`iox2_waitset_try_wait_and_process_events()`](crate::iox2_waitset_try_wait_and_process_events())
115+
/// * [`iox2_waitset_wait_and_process()`](crate::iox2_waitset_wait_and_process())
116+
/// * [`iox2_waitset_try_wait_and_process()`](crate::iox2_waitset_try_wait_and_process())
117117
///
118118
/// # Safety
119119
/// * `handle` must be valid and provided by the previously mentioned functions.

0 commit comments

Comments
 (0)