-
Notifications
You must be signed in to change notification settings - Fork 65
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
examples: add an example using tokio's event-loop #119
Conversation
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.
Thank your for the pull request, @ceyusa! I've left some comments.
Could you also please change the name of the example? Something like issue-120-workaround.rs
. I'm not set on that name, but the name should make clear this is a workaround for a problem with the API.
@@ -35,6 +35,7 @@ futures = { version = "0.1", optional = true } | |||
inotify-sys = "0.1.3" | |||
libc = "0.2" | |||
mio = { version = "0.6", optional = true } | |||
tokio = { version = "0.1", optional = true } |
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.
Is it possible to move that dependency to [dev-dependencies]
, or will that cause problems, due to the dependency being optional?
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.
yes, it causes problems because of that
examples/tokio-streams.rs
Outdated
use tokio::prelude::*; | ||
|
||
/// XXX: hic sunt dracones | ||
static mut BUFFER: [u8; 32] = [0; 32]; |
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.
You can move the static into the function. Still bad, as it still requires unsafe, but at least it won't be accessible from anywhere else.
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.
Could you also add a comment explaining that this is a workaround for #120, and should be avoided, if possible?
This example shows how to use inotify's stream as future polled by tokio's event loop which is cheap in computational terms using Rust idioms. It also shows how to workaround issue hannobraun#120 hannobraun#120
Thanks again, @ceyusa! |
This example shows how to use inotify's stream as future polled by tokio's event loop which is cheap in computational terms using Rust idioms.