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

Expose waitable handles in Windows #152

Merged
merged 3 commits into from
Jan 13, 2024
Merged

Expose waitable handles in Windows #152

merged 3 commits into from
Jan 13, 2024

Conversation

notgull
Copy link
Member

@notgull notgull commented Sep 23, 2023

This commit allows waitable handles to be polled in Windows. This allows I/O constructs like processes, mutexes and waitable events be registered into the poller and be polled just like anything else.

cc #25

@notgull
Copy link
Member Author

notgull commented Dec 2, 2023

OpenBSD CI failed spuriously I think

@notgull notgull requested a review from fogti December 2, 2023 19:18
match self {
Self::Socket(raw) => poller.delete(unsafe { BorrowedSocket::borrow_raw(*raw) }),
Self::Handle(handle) => {
poller.remove_waitable(unsafe { BorrowedHandle::borrow_raw(*handle) })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poller API nitpick (although not really related to this PR): why are the poller methods for sockets and handles named wildly different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I missed that when I was implementing that API in smol-rs/polling#111

@fogti
Copy link
Member

fogti commented Dec 3, 2023

looks good overall, although I'll need to find time to test this on windows...

@h33p
Copy link

h33p commented Dec 6, 2023

I'm able to use this to integrate completion I/O with async-io memflow/mfio@088e32c

Works on wine:

❯ WINEDEBUG="-all" RUST_BACKTRACE=1 RUST_LOG="mfio_rt::test_suite=trace,mfio_rt=debug" MFIO_FS_BACKENDS=iocp wine64 ./target/x86_64-pc-windows-gnu/release/deps/mfio_rt-46d6aa56a31792b4.exe smol

running 36 tests
test native::suite_tests::smol::net_tests_all::tcp_connect ... ok
test native::suite_tests::smol::net_tests_all::tcp_listen ... ok
test native::suite_tests::smol::net_tests_default::tcp_connect ... ok
test native::suite_tests::smol::net_tests_all::tcp_send_seq ... ok
test native::suite_tests::smol::net_tests_all::tcp_send_con ... ok
test native::suite_tests::smol::net_tests_all::tcp_receive_seq ... ok
test native::suite_tests::smol::net_tests_all::tcp_receive_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_listen ... ok
test native::suite_tests::smol::net_tests_all::tcp_echo_server_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_echo_server_seq ... ok
test native::suite_tests::smol::net_tests_default::tcp_echo_client_con ... ok
test native::suite_tests::smol::net_tests_all::tcp_echo_server_seq ... ok
test native::suite_tests::smol::net_tests_default::tcp_receive_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_echo_server_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_send_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_receive_seq ... ok
test native::suite_tests::smol::net_tests_default::tcp_send_seq ... ok
test native::suite_tests::smol::tests_all::dirs_equal ... ok
test native::suite_tests::smol::tests_all::files_equal ... ok
test native::suite_tests::smol::net_tests_all::tcp_echo_client_con ... ok
test native::suite_tests::smol::net_tests_default::tcp_echo_client_seq ... ok
test native::suite_tests::smol::tests_all::files_equal_rel ... ok
test native::suite_tests::smol::tests_default::dirs_equal ... ok
test native::suite_tests::smol::tests_all::writes_equal ... ok
test native::suite_tests::smol::tests_default::files_equal ... ok
test native::suite_tests::smol::tests_all::writes_equal_rel ... ok
test native::suite_tests::smol::tests_default::files_equal_rel ... ok
test native::suite_tests::smol::tests_all::walk_dirs ... ok
test native::suite_tests::smol::tests_default::writes_equal ... ok
test native::suite_tests::smol::tests_default::walk_dirs ... ok
test native::suite_tests::smol::tests_default::writes_equal_rel ... ok
test native::suite_tests::smol::net_tests_all::tcp_echo_client_seq ... ok
test native::suite_tests::smol::tests_default::all_tests_con ... ok
test native::suite_tests::smol::tests_default::all_tests_seq ... ok
test native::suite_tests::smol::tests_all::all_tests_con ... ok
test native::suite_tests::smol::tests_all::all_tests_seq ... ok

Do not have a windows native machine at hand, however.

This commit allows waitable handles to be polled in Windows. This allows
I/O constructs like processes, mutexes and waitable events be registered
into the poller and be polled just like anything else.

cc #25

Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
@notgull notgull merged commit fefe804 into master Jan 13, 2024
21 checks passed
@notgull notgull deleted the notgull/waitable branch January 13, 2024 20:13
@notgull notgull mentioned this pull request Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants