Skip to content

Commit

Permalink
m(windows): Reimplement Wepoll in Rust (#88)
Browse files Browse the repository at this point in the history
Reimplements the C-based wepoll backend in Rust, using some handwritten code. This PR also implements bindings to the I/O Completion Ports and \Device\Afd APIs. For more information on the latter, see my blog post on the subject: https://notgull.github.io/device-afd/

Note that the IOCP API is wrapped using a `Pin`-oriented "CompletionHandle" system that is relatively brittle. This should be replaced with a better model when one becomes available.
  • Loading branch information
notgull authored Mar 6, 2023
1 parent e85331c commit 24900fb
Show file tree
Hide file tree
Showing 10 changed files with 1,826 additions and 267 deletions.
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ version = "2.5.2"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
edition = "2018"
rust-version = "1.47"
description = "Portable interface to epoll, kqueue, event ports, and wepoll"
description = "Portable interface to epoll, kqueue, event ports, and IOCP"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/smol-rs/polling"
keywords = ["mio", "epoll", "kqueue", "iocp", "wepoll"]
keywords = ["mio", "epoll", "kqueue", "iocp"]
categories = ["asynchronous", "network-programming", "os"]
exclude = ["/.*"]

Expand All @@ -32,13 +32,19 @@ autocfg = "1"
libc = "0.2.77"

[target.'cfg(windows)'.dependencies]
wepoll-ffi = { version = "0.1.2", features = ["null-overlapped-wakeups-patch"] }
bitflags = "1.3.2"
concurrent-queue = "2.1.0"
pin-project-lite = "0.2.9"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.45"
features = [
"Win32_Networking_WinSock",
"Win32_System_IO",
"Win32_Foundation"
"Win32_System_LibraryLoader",
"Win32_System_WindowsProgramming",
"Win32_Storage_FileSystem",
"Win32_Foundation",
]

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ https://crates.io/crates/polling)
[![Documentation](https://docs.rs/polling/badge.svg)](
https://docs.rs/polling)

Portable interface to epoll, kqueue, event ports, and wepoll.
Portable interface to epoll, kqueue, event ports, and IOCP.

Supported platforms:
- [epoll](https://en.wikipedia.org/wiki/Epoll): Linux, Android
- [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD,
DragonFly BSD
- [event ports](https://illumos.org/man/port_create): illumos, Solaris
- [poll](https://en.wikipedia.org/wiki/Poll_(Unix)): VxWorks, Fuchsia, other Unix systems
- [wepoll](https://github.com/piscisaureus/wepoll): Windows, Wine (version 7.13+)
- [IOCP](https://learn.microsoft.com/en-us/windows/win32/fileio/i-o-completion-ports): Windows, Wine (version 7.13+)

Polling is done in oneshot mode, which means interest in I/O events needs to be reset after
an event is delivered if we're interested in the next event of the same kind.
Expand Down
Loading

0 comments on commit 24900fb

Please sign in to comment.