Help with writing low level future using `mio`
⚓ Rust 📅 2025-09-26 👤 surdeus 👁️ 8Hi. I want to write custom low-level Future using mio as abstraction over epoll(2). My basic understanding is that I should open file descriptor with NONBLOCK option, and then in Future::poll issue a syscall. If it succeeds then I return Poll::Ready, and if it fails with EWOULDBLOCK I have to register file descriptor to mio::Poll with proper interest, store waker provided by std::task::Context and once I get woken up by mio, then I should call wake on stored waker.
I know that tokio uses mio as its reactor and that tokio's runtime runs a separate thread that manages mio::Poll instance. I don't want to manage separate mio::Poll instance. I want to hook into reactor already managed by tokio. However after reading documentation I don't see how it can be done. I know that some libraries are tied to executor, because they rely on executor's reactor, so there must be some way to connect to it, mustn't it?
Can you please explain how to do it? Show some 3rd party (not tokio project's) library that uses mio as reactor for waiting futures? And if my reasoning is flawed, can you please explain where I make mistake?
3 posts - 2 participants
🏷️ Rust_feed