Skip to content
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

Merged
merged 1 commit into from
Sep 7, 2018

Conversation

ceyusa
Copy link
Contributor

@ceyusa ceyusa commented Sep 5, 2018

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.

Copy link
Owner

@hannobraun hannobraun left a 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 }
Copy link
Owner

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?

Copy link
Contributor Author

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

use tokio::prelude::*;

/// XXX: hic sunt dracones
static mut BUFFER: [u8; 32] = [0; 32];
Copy link
Owner

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.

Copy link
Owner

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
@hannobraun hannobraun merged commit b85c21a into hannobraun:master Sep 7, 2018
@hannobraun
Copy link
Owner

Thanks again, @ceyusa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants