eclipse-iceoryx / eclipse-iceoryx/iceoryx2

Async API for wait_and_process

Open
#627 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
187
Avg merge
1d 23h
Merged PRs (30d)
47

Description

The following code :

auto main() -> int {
auto node = NodeBuilder().create().expect("successful node creation");

auto subscriber = CustomSubscriber::create(node, ServiceName::create("My/Funk/ServiceName").expect(""));

auto waitset = WaitSetBuilder().create().expect("");
// The subscriber is attached as a deadline, meaning that we expect some activity
// latest after the deadline has passed.
auto subscriber_guard = waitset.attach_deadline(subscriber, DEADLINE).expect("");
auto on_event = [&](WaitSetAttachmentId attachment_id) {
// If we have received a new event on the subscriber we handle it.
if (attachment_id.has_event_from(subscriber_guard)) {
subscriber.handle_event();
// If the subscriber did not receive an event until DEADLINE has
// passed, we print out a warning.
} else if (attachment_id.has_missed_deadline(subscriber_guard)) {
std::cout << "Contract violation! The subscriber did not receive a message for " << DEADLINE << std::endl;
}
return CallbackProgression::Continue;
};
waitset.wait_and_process(on_event).expect("");

//some other function
// ...
std::cout << "exit" << std::endl;

return 0;
}

In this code, “waitset.wait_and_process(on_event).expect(""); “ is a blocking function. If there are any other function calls after this, they will be blocked until the wait_and_process method finishes executing. Thus,does we have an async_wait_and_process, which is like to iceoryx1:

listener_ptr
->attachEvent(*subscriber_ptr,
iox::popo::SubscriberEvent::DATA_RECEIVED,
iox::popo::createNotificationCallback(OnReceivedCallback, *handle_ptr))
.or_else([](auto) {
std::cerr << "Unable to attach a subscriber!" << std::endl;
std::exit(EXIT_FAILURE);
});

Contributor guide

Open the contributing guide

Research direction

Start with the waitset.wait_and_process(on_event) entry point shown in the example and compare it with the referenced iceoryx1 listener and attachEvent callback model. Clarify the async operation's execution and completion behavior, including how callers continue with subsequent work. Done means the proposed async API has defined behavior and validation for the non-blocking use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
api, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.