-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align examples and remove reading from stdin #768
Conversation
1 similar comment
zenoh-ext/examples/z_query_sub.rs
Outdated
println!("Enter 'q' to quit..."); | ||
let mut stdin = async_std::io::stdin(); | ||
let mut input = [0_u8]; | ||
println!("Press CTRL-C to quit..."); | ||
loop { | ||
select!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select is no longer necessary, just have a while let Ok(sample) = subscriber.recv().await { .. }
.
examples/examples/z_sub_thr.rs
Outdated
_ => std::thread::yield_now(), | ||
} | ||
println!("Press CTRL-C to quit..."); | ||
loop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better way than looping is perhaps to just park the thread.
println!("Enter 'q' to quit..."); | ||
let mut stdin = async_std::io::stdin(); | ||
let mut input = [0_u8]; | ||
println!("Press CTRL-C to quit..."); | ||
loop { | ||
select!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select is no longer necessary, just have a while let Ok(sample) = subscriber.recv().await { .. }
.
examples/examples/z_sub.rs
Outdated
println!("Enter 'q' to quit..."); | ||
let mut stdin = async_std::io::stdin(); | ||
let mut input = [0_u8]; | ||
println!("Press CTRL-C to quit..."); | ||
loop { | ||
select!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select is no longer necessary, just have a while let Ok(sample) = subscriber.recv().await { .. }
.
println!("Enter 'q' to quit..."); | ||
let mut stdin = async_std::io::stdin(); | ||
let mut input = [0u8]; | ||
println!("Press CTRL-C to quit..."); | ||
loop { | ||
select!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select is no longer necessary, just have a while let Ok(sample) = subscriber.recv().await { .. }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one has a subscriber and a queryable, I believe a select is necessary.
examples/examples/z_queryable.rs
Outdated
println!("Enter 'q' to quit, 'e' to reply an error to next query..."); | ||
let mut stdin = async_std::io::stdin(); | ||
let mut input = [0_u8]; | ||
println!("Press CTRL-C to quit..."); | ||
loop { | ||
select!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select is no longer necessary, just have a while let Ok(query) = queryable.recv().await { .. }
.
These changes remove reading from stdin for all examples, and align their behaviors and outputs across projects.
This PR is part of an effort across currently active Zenoh projects. To maintain examples' implementations as close to each other as possible, any changes identified in other projects will be replicated in this PR. As such, please do not merge these changes until all PRs are ready for merging.
Related PRs: