Skip to content

Commit 71dd900

Browse files
committed
[#390] Rename event_from -> has_event_from, deadline_from -> has_missed_deadline
1 parent ab4b795 commit 71dd900

File tree

7 files changed

+63
-62
lines changed

7 files changed

+63
-62
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ 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.
2727
/// It can also be used to determine the origin of an event in [`WaitSet::run()`] or
28-
/// [`WaitSet::run_once()`] via [`WaitSetAttachmentId::event_from()`] or [`WaitSetAttachmentId::deadline_from()`].
28+
/// [`WaitSet::run_once()`] via [`WaitSetAttachmentId::has_event_from()`] or
29+
/// [`WaitSetAttachmentId::has_missed_deadline()`].
2930
template <ServiceType S>
3031
class WaitSetGuard {
3132
public:
@@ -66,10 +67,10 @@ class WaitSetAttachmentId {
6667

6768
/// Returns true if an event was emitted from a notification or deadline attachment
6869
/// corresponding to [`WaitSetGuard`].
69-
auto event_from(const WaitSetGuard<S>& guard) const -> bool;
70+
auto has_event_from(const WaitSetGuard<S>& guard) const -> bool;
7071

7172
/// Returns true if the deadline for the attachment corresponding to [`WaitSetGuard`] was missed.
72-
auto deadline_from(const WaitSetGuard<S>& guard) const -> bool;
73+
auto has_missed_deadline(const WaitSetGuard<S>& guard) const -> bool;
7374

7475
private:
7576
explicit WaitSetAttachmentId(iox2_waitset_attachment_id_h handle);

iceoryx2-ffi/cxx/src/waitset.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ auto WaitSetAttachmentId<S>::from_guard(const WaitSetGuard<S>& guard) -> WaitSet
5151
}
5252

5353
template <ServiceType S>
54-
auto WaitSetAttachmentId<S>::event_from(const WaitSetGuard<S>& guard) const -> bool {
55-
return iox2_waitset_attachment_id_event_from(&m_handle, &guard.m_handle);
54+
auto WaitSetAttachmentId<S>::has_event_from(const WaitSetGuard<S>& guard) const -> bool {
55+
return iox2_waitset_attachment_id_has_event_from(&m_handle, &guard.m_handle);
5656
}
5757

5858
template <ServiceType S>
59-
auto WaitSetAttachmentId<S>::deadline_from(const WaitSetGuard<S>& guard) const -> bool {
60-
return iox2_waitset_attachment_id_deadline_from(&m_handle, &guard.m_handle);
59+
auto WaitSetAttachmentId<S>::has_missed_deadline(const WaitSetGuard<S>& guard) const -> bool {
60+
return iox2_waitset_attachment_id_has_missed_deadline(&m_handle, &guard.m_handle);
6161
}
6262

6363
template <ServiceType S>

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ TYPED_TEST(WaitSetTest, interval_attachment_blocks_for_at_least_timeout) {
156156
auto result = sut.run([&](auto attachment_id) {
157157
callback_called = true;
158158
sut.stop();
159-
ASSERT_THAT(attachment_id.event_from(guard), Eq(true));
160-
ASSERT_THAT(attachment_id.deadline_from(guard), Eq(false));
159+
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
160+
ASSERT_THAT(attachment_id.has_missed_deadline(guard), Eq(false));
161161
});
162162

163163
auto end = std::chrono::steady_clock::now();
@@ -178,8 +178,8 @@ TYPED_TEST(WaitSetTest, deadline_attachment_blocks_for_at_least_timeout) {
178178
auto result = sut.run([&](auto attachment_id) {
179179
callback_called = true;
180180
sut.stop();
181-
ASSERT_THAT(attachment_id.event_from(guard), Eq(false));
182-
ASSERT_THAT(attachment_id.deadline_from(guard), Eq(true));
181+
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(false));
182+
ASSERT_THAT(attachment_id.has_missed_deadline(guard), Eq(true));
183183
});
184184

185185
auto end = std::chrono::steady_clock::now();
@@ -204,8 +204,8 @@ TYPED_TEST(WaitSetTest, deadline_attachment_wakes_up_when_notified) {
204204
auto result = sut.run([&](auto attachment_id) {
205205
callback_called = true;
206206
sut.stop();
207-
ASSERT_THAT(attachment_id.event_from(guard), Eq(true));
208-
ASSERT_THAT(attachment_id.deadline_from(guard), Eq(false));
207+
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
208+
ASSERT_THAT(attachment_id.has_missed_deadline(guard), Eq(false));
209209
});
210210

211211
notifier_thread.join();
@@ -227,8 +227,8 @@ TYPED_TEST(WaitSetTest, notification_attachment_wakes_up_when_notified) {
227227
auto result = sut.run([&](auto attachment_id) {
228228
callback_called = true;
229229
sut.stop();
230-
ASSERT_THAT(attachment_id.event_from(guard), Eq(true));
231-
ASSERT_THAT(attachment_id.deadline_from(guard), Eq(false));
230+
ASSERT_THAT(attachment_id.has_event_from(guard), Eq(true));
231+
ASSERT_THAT(attachment_id.has_missed_deadline(guard), Eq(false));
232232
});
233233

234234
notifier_thread.join();
@@ -268,7 +268,7 @@ TYPED_TEST(WaitSetTest, triggering_everything_works) {
268268

269269
sut.run_once([&](auto attachment_id) {
270270
for (uint64_t idx = 0; idx < guards.size(); ++idx) {
271-
if (attachment_id.event_from(guards[idx])) {
271+
if (attachment_id.has_event_from(guards[idx])) {
272272
was_triggered[idx] = true;
273273
break;
274274
}

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub unsafe extern "C" fn iox2_waitset_stop(handle: iox2_waitset_h_ref) {
307307
/// [`iox2_waitset_h`]. As soon as the attachment receives data, the WaitSet
308308
/// wakes up in [`iox2_waitset_run()`] and informs the user.
309309
///
310-
/// With [`iox2_waitset_attachment_id_event_from()`](crate::iox2_waitset_attachment_id_event_from())
310+
/// 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
312312
/// [`iox2_waitset_guard_h`].
313313
///
@@ -383,11 +383,11 @@ pub unsafe extern "C" fn iox2_waitset_attach_notification(
383383
/// [`iox2_waitset_h`]. As soon as the attachment receives data or the deadline
384384
/// was missed, the WaitSet wakes up in [`iox2_waitset_run()`] and informs the user.
385385
///
386-
/// With [`iox2_waitset_attachment_id_event_from()`](crate::iox2_waitset_attachment_id_event_from())
386+
/// 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
388388
/// [`iox2_waitset_guard_h`].
389389
/// If the deadline was hit the function
390-
/// [`iox2_waitset_attachment_id_deadline_from()`](crate::iox2_waitset_attachment_id_deadline_from())
390+
/// [`iox2_waitset_attachment_id_has_missed_deadline()`](crate::iox2_waitset_attachment_id_has_missed_deadline())
391391
/// can be used to identify it.
392392
///
393393
/// # Return
@@ -471,7 +471,7 @@ pub unsafe extern "C" fn iox2_waitset_attach_deadline(
471471
/// Attaches an interval to the [`iox2_waitset_h`]. As soon as the interval has passed
472472
/// the WaitSet wakes up in [`iox2_waitset_run()`] and informs the user.
473473
///
474-
/// With [`iox2_waitset_attachment_id_event_from()`](crate::iox2_waitset_attachment_id_event_from())
474+
/// 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
476476
/// [`iox2_waitset_guard_h`].
477477
///
@@ -550,11 +550,11 @@ pub unsafe extern "C" fn iox2_waitset_attach_interval(
550550
/// for every events that was received and the corresponding owning [`iox2_waitset_attachment_id_h`]
551551
/// is provided as input argument, as well as the `callback_ctx`.
552552
///
553-
/// With [`iox2_waitset_attachment_id_event_from()`](crate::iox2_waitset_attachment_id_event_from())
553+
/// With [`iox2_waitset_attachment_id_has_event_from()`](crate::iox2_waitset_attachment_id_has_event_from())
554554
/// the origin of the event can be determined from its corresponding
555555
/// [`iox2_waitset_guard_h`].
556556
/// If the deadline was hit the function
557-
/// [`iox2_waitset_attachment_id_deadline_from()`](crate::iox2_waitset_attachment_id_deadline_from())
557+
/// [`iox2_waitset_attachment_id_has_missed_deadline()`](crate::iox2_waitset_attachment_id_has_missed_deadline())
558558
/// can be used to identify it.
559559
///
560560
/// # Return
@@ -613,11 +613,11 @@ pub unsafe extern "C" fn iox2_waitset_run_once(
613613
/// The infinite loop is interrupted either by a `SIGINT` or `SIGTERM` signal or
614614
/// when the user has called [`iox2_waitset_stop()`].
615615
///
616-
/// With [`iox2_waitset_attachment_id_event_from()`](crate::iox2_waitset_attachment_id_event_from())
616+
/// With [`iox2_waitset_attachment_id_has_event_from()`](crate::iox2_waitset_attachment_id_has_event_from())
617617
/// the origin of the event can be determined from its corresponding
618618
/// [`iox2_waitset_guard_h`].
619619
/// If the deadline was hit the function
620-
/// [`iox2_waitset_attachment_id_deadline_from()`](crate::iox2_waitset_attachment_id_deadline_from())
620+
/// [`iox2_waitset_attachment_id_has_missed_deadline()`](crate::iox2_waitset_attachment_id_has_missed_deadline())
621621
/// can be used to identify it.
622622
///
623623
/// # Return

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub unsafe extern "C" fn iox2_waitset_attachment_id_less(
197197
/// * `handle` must be valid and non-null.
198198
/// * `guard` must be valid and non-null.
199199
#[no_mangle]
200-
pub unsafe extern "C" fn iox2_waitset_attachment_id_event_from(
200+
pub unsafe extern "C" fn iox2_waitset_attachment_id_has_event_from(
201201
handle: iox2_waitset_attachment_id_h_ref,
202202
guard: iox2_waitset_guard_h_ref,
203203
) -> bool {
@@ -212,12 +212,12 @@ pub unsafe extern "C" fn iox2_waitset_attachment_id_event_from(
212212
.value
213213
.as_ref()
214214
.ipc
215-
.event_from(&*guard.value.as_ref().ipc),
215+
.has_event_from(&*guard.value.as_ref().ipc),
216216
iox2_service_type_e::LOCAL => attachment_id
217217
.value
218218
.as_ref()
219219
.local
220-
.event_from(&*guard.value.as_ref().local),
220+
.has_event_from(&*guard.value.as_ref().local),
221221
}
222222
}
223223

@@ -228,7 +228,7 @@ pub unsafe extern "C" fn iox2_waitset_attachment_id_event_from(
228228
/// * `handle` must be valid and non-null.
229229
/// * `guard` must be valid and non-null.
230230
#[no_mangle]
231-
pub unsafe extern "C" fn iox2_waitset_attachment_id_deadline_from(
231+
pub unsafe extern "C" fn iox2_waitset_attachment_id_has_missed_deadline(
232232
handle: iox2_waitset_attachment_id_h_ref,
233233
guard: iox2_waitset_guard_h_ref,
234234
) -> bool {
@@ -243,12 +243,12 @@ pub unsafe extern "C" fn iox2_waitset_attachment_id_deadline_from(
243243
.value
244244
.as_ref()
245245
.ipc
246-
.deadline_from(&*guard.value.as_ref().ipc),
246+
.has_missed_deadline(&*guard.value.as_ref().ipc),
247247
iox2_service_type_e::LOCAL => attachment_id
248248
.value
249249
.as_ref()
250250
.local
251-
.deadline_from(&*guard.value.as_ref().local),
251+
.has_missed_deadline(&*guard.value.as_ref().local),
252252
}
253253
}
254254

iceoryx2/src/port/waitset.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
//! let guard = waitset.attach_notification(&listener)?;
5959
//!
6060
//! let on_event = |attachment_id: WaitSetAttachmentId<ipc::Service>| {
61-
//! if attachment_id.event_from(&guard) {
61+
//! if attachment_id.has_event_from(&guard) {
6262
//! while let Ok(Some(event_id)) = listener.try_wait_one() {
6363
//! println!("received notification {:?}", event_id);
6464
//! }
@@ -89,11 +89,11 @@
8989
//! let guard = waitset.attach_deadline(&listener, listener_deadline)?;
9090
//!
9191
//! let on_event = |attachment_id: WaitSetAttachmentId<ipc::Service>| {
92-
//! if attachment_id.event_from(&guard) {
92+
//! if attachment_id.has_event_from(&guard) {
9393
//! while let Ok(Some(event_id)) = listener.try_wait_one() {
9494
//! println!("received notification {:?}", event_id);
9595
//! }
96-
//! } else if attachment_id.deadline_from(&guard) {
96+
//! } else if attachment_id.has_missed_deadline(&guard) {
9797
//! println!("Oh no, we hit the deadline without receiving any kind of event");
9898
//! }
9999
//! };
@@ -126,9 +126,9 @@
126126
//! let guard_2 = waitset.attach_interval(pub_2_period)?;
127127
//!
128128
//! let on_event = |attachment_id: WaitSetAttachmentId<ipc::Service>| {
129-
//! if attachment_id.event_from(&guard_1) {
129+
//! if attachment_id.has_event_from(&guard_1) {
130130
//! publisher_1.send_copy(123);
131-
//! } else if attachment_id.event_from(&guard_2) {
131+
//! } else if attachment_id.has_event_from(&guard_2) {
132132
//! publisher_2.send_copy(456);
133133
//! }
134134
//! };
@@ -365,7 +365,7 @@ impl<Service: crate::service::Service> WaitSetAttachmentId<Service> {
365365

366366
/// Returns true if an event was emitted from a notification or deadline attachment
367367
/// corresponding to [`WaitSetGuard`].
368-
pub fn event_from(&self, other: &WaitSetGuard<Service>) -> bool {
368+
pub fn has_event_from(&self, other: &WaitSetGuard<Service>) -> bool {
369369
let other_attachment = WaitSetAttachmentId::from_guard(other);
370370
if let AttachmentIdType::Deadline(other_waitset, other_reactor_idx, _) =
371371
other_attachment.attachment_type
@@ -381,7 +381,7 @@ impl<Service: crate::service::Service> WaitSetAttachmentId<Service> {
381381
}
382382

383383
/// Returns true if the deadline for the attachment corresponding to [`WaitSetGuard`] was missed.
384-
pub fn deadline_from(&self, other: &WaitSetGuard<Service>) -> bool {
384+
pub fn has_missed_deadline(&self, other: &WaitSetGuard<Service>) -> bool {
385385
if let AttachmentIdType::Deadline(..) = self.attachment_type {
386386
self.attachment_type == WaitSetAttachmentId::from_guard(other).attachment_type
387387
} else {

iceoryx2/tests/waitset_tests.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ mod waitset {
198198
let mut receiver_2_triggered = false;
199199

200200
sut.run_once(|attachment_id| {
201-
if attachment_id.event_from(&listener_1_guard) {
201+
if attachment_id.has_event_from(&listener_1_guard) {
202202
listener_1_triggered = true;
203-
} else if attachment_id.event_from(&listener_2_guard) {
203+
} else if attachment_id.has_event_from(&listener_2_guard) {
204204
listener_2_triggered = true;
205-
} else if attachment_id.event_from(&receiver_1_guard) {
205+
} else if attachment_id.has_event_from(&receiver_1_guard) {
206206
receiver_1_triggered = true;
207-
} else if attachment_id.event_from(&receiver_2_guard) {
207+
} else if attachment_id.has_event_from(&receiver_2_guard) {
208208
receiver_2_triggered = true;
209209
} else {
210210
test_fail!("only attachments shall trigger");
@@ -233,8 +233,8 @@ mod waitset {
233233
let start = Instant::now();
234234
sut.run_once(|id| {
235235
callback_called = true;
236-
assert_that!(id.event_from(&tick_guard), eq true);
237-
assert_that!(id.deadline_from(&tick_guard), eq false);
236+
assert_that!(id.has_event_from(&tick_guard), eq true);
237+
assert_that!(id.has_missed_deadline(&tick_guard), eq false);
238238
})
239239
.unwrap();
240240

@@ -256,7 +256,7 @@ mod waitset {
256256

257257
let start = Instant::now();
258258
sut.run_once(|id| {
259-
assert_that!(id.deadline_from(&guard), eq true);
259+
assert_that!(id.has_missed_deadline(&guard), eq true);
260260
})
261261
.unwrap();
262262

@@ -296,13 +296,13 @@ mod waitset {
296296
let mut receiver_2_triggered = false;
297297

298298
sut.run_once(|attachment_id| {
299-
if attachment_id.event_from(&listener_1_guard) {
299+
if attachment_id.has_event_from(&listener_1_guard) {
300300
listener_1_triggered = true;
301-
} else if attachment_id.deadline_from(&listener_2_guard) {
301+
} else if attachment_id.has_missed_deadline(&listener_2_guard) {
302302
listener_2_triggered = true;
303-
} else if attachment_id.event_from(&receiver_1_guard) {
303+
} else if attachment_id.has_event_from(&receiver_1_guard) {
304304
receiver_1_triggered = true;
305-
} else if attachment_id.deadline_from(&receiver_2_guard) {
305+
} else if attachment_id.has_missed_deadline(&receiver_2_guard) {
306306
receiver_2_triggered = true;
307307
} else {
308308
test_fail!("only attachments shall trigger");
@@ -336,13 +336,13 @@ mod waitset {
336336
let mut tick_4_triggered = false;
337337

338338
sut.run_once(|attachment_id| {
339-
if attachment_id.event_from(&tick_1_guard) {
339+
if attachment_id.has_event_from(&tick_1_guard) {
340340
tick_1_triggered = true;
341-
} else if attachment_id.event_from(&tick_2_guard) {
341+
} else if attachment_id.has_event_from(&tick_2_guard) {
342342
tick_2_triggered = true;
343-
} else if attachment_id.event_from(&tick_3_guard) {
343+
} else if attachment_id.has_event_from(&tick_3_guard) {
344344
tick_3_triggered = true;
345-
} else if attachment_id.event_from(&tick_4_guard) {
345+
} else if attachment_id.has_event_from(&tick_4_guard) {
346346
tick_4_triggered = true;
347347
} else {
348348
test_fail!("only attachments shall trigger");
@@ -393,21 +393,21 @@ mod waitset {
393393
let mut deadline_2_missed = false;
394394

395395
sut.run_once(|attachment_id| {
396-
if attachment_id.event_from(&tick_1_guard) {
396+
if attachment_id.has_event_from(&tick_1_guard) {
397397
tick_1_triggered = true;
398-
} else if attachment_id.event_from(&tick_2_guard) {
398+
} else if attachment_id.has_event_from(&tick_2_guard) {
399399
tick_2_triggered = true;
400-
} else if attachment_id.event_from(&notification_1_guard) {
400+
} else if attachment_id.has_event_from(&notification_1_guard) {
401401
notification_1_triggered = true;
402-
} else if attachment_id.event_from(&notification_2_guard) {
402+
} else if attachment_id.has_event_from(&notification_2_guard) {
403403
notification_2_triggered = true;
404-
} else if attachment_id.event_from(&deadline_1_guard) {
404+
} else if attachment_id.has_event_from(&deadline_1_guard) {
405405
deadline_1_triggered = true;
406-
} else if attachment_id.event_from(&deadline_2_guard) {
406+
} else if attachment_id.has_event_from(&deadline_2_guard) {
407407
deadline_2_triggered = true;
408-
} else if attachment_id.deadline_from(&deadline_1_guard) {
408+
} else if attachment_id.has_missed_deadline(&deadline_1_guard) {
409409
deadline_1_missed = true;
410-
} else if attachment_id.deadline_from(&deadline_2_guard) {
410+
} else if attachment_id.has_missed_deadline(&deadline_2_guard) {
411411
deadline_2_missed = true;
412412
} else {
413413
test_fail!("only attachments shall trigger");
@@ -445,9 +445,9 @@ mod waitset {
445445
let mut received_event = false;
446446

447447
sut.run_once(|attachment_id| {
448-
if attachment_id.event_from(&deadline_1_guard) {
448+
if attachment_id.has_event_from(&deadline_1_guard) {
449449
received_event = true;
450-
} else if attachment_id.deadline_from(&deadline_1_guard) {
450+
} else if attachment_id.has_missed_deadline(&deadline_1_guard) {
451451
missed_deadline = true;
452452
} else {
453453
test_fail!("only attachments shall trigger");

0 commit comments

Comments
 (0)