-
Notifications
You must be signed in to change notification settings - Fork 68
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
Support VxWorks, Fuchsia and other Unix systems by using poll #26
Conversation
Some quick questions before I do a deeper dive into the code... Suppose a thread is blocked on
|
Thanks for pointing that out, I didn't consider those cases - I'll convert this to a draft. |
Ok, I think I've handled those cases now. Any call to |
src/poll.rs
Outdated
/// The list of `pollfds` taken by poll. | ||
/// | ||
/// The first file descriptor is always present and is used to notify the poller. It is also | ||
/// stored in `notify_read`. | ||
/// | ||
/// If the fd stored in here is `REMOVE_FD`, it should be removed. | ||
poll_fds: Vec<libc::pollfd>, | ||
/// The map of each file descriptor to data associated with it. This does not include the file | ||
/// descriptors `notify_read` or `notify_write`. | ||
fd_data: HashMap<RawFd, FdData>, |
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 seems to just implement an separately-ordered, hashmap. Why don't we pull in something like indexmap
for this, or do we require some feature it doesn't have? (if true, which?)
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.
I'm averse to adding a dependency for this implementation, mostly because it would require a really long cfg
in the Cargo.toml 😄. However, this comment did make me realize that I can make the implementation more efficient and simpler by using swap_remove
instead of marking fds as removed and later removing them.
We use [target."cfg(unix)".dependencies]
libc = { version = "0.2.77", features = ["extra_traits"] } but } else if #[cfg(any(
target_os = "vxworks",
target_os = "fuchsia",
unix,
))] {
mod poll;
use poll as sys; and // std::os::unix doesn't exist on Fuchsia
use libc::c_int as RawFd; This is a mismatch between cfg-targets and should be fixed. |
Ah right, the reason Fuchsia was compiling before is that it hasn't actually been changed to a
It still applies, because the actual |
Ah ok, didn't notice that |
I have tested it on Haiku, works for me. Rustup indeed does not support Haiku, but rust can be installed with |
I haven't reviewed this PR yet, but in mio, (IIUC) there was a discussion on |
By storing all file descriptors inside a |
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 looks good to me. Thanks for working on this!
(I'm not familiar with the platforms mentioned here, but I have tweaked this patch a bit and tested polling, async-io, and async-net on macOS.)
-
Could you update "supported platforms" docs on readme?
-
Could you add Fuchsia to cross workflow on CI? Probably something like:
- name: Fuchsia if: startsWith(matrix.os, 'ubuntu') run: cross build --target x86_64-fuchsia
Also, would it be possible to add tests for the cases mentioned in #26 (comment) by Stjepan? I don't think tests for such a case currently exist.
|
OK, I have done everything suggested 😊 Hopefully CI will pass... |
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.
LGTM, Thanks @Kestrer!
Published in v2.2.0. |
Closes #20.
Notes:
extra_traits
feature tolibc
to#[derive(Debug)]
on the polling implementation. This can be done manually to avoid activating the feature, if that's something you care about.#[derive(Clone, Copy)]
onEvent
. It seems to be fine asEvent
's interface is already fully exposed.epoll
and I have checked it compiles on Fuchsia (VxWorks and Haiku aren't supported by Rustup).