| Crates.io | mio_channel |
| lib.rs | mio_channel |
| version | 0.2.0 |
| created_at | 2022-11-11 12:54:22.505539+00 |
| updated_at | 2025-07-04 03:11:32.081251+00 |
| description | Provide a wrapper of the standard channel that can be polled with Mio. |
| homepage | |
| repository | https://github.com/oh-jinsu/mio_channel |
| max_upload_size | |
| id | 712835 |
| size | 12,659 |
Provide a wrapper of the standard channel that can be polled with Mio.
const CHANNEL: mio::Token = mio::Token(0);
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut poll = mio::Poll::new()?;
let mut events = mio::Events::with_capacity(2);
let (tx, mut rx) = mio_channel::channel();
poll.registry().register(&mut rx, CHANNEL, mio::Interest::READABLE)?;
let handler = std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_millis(1000));
let _ = tx.send("Hello world!");
});
poll.poll(&mut events, None)?;
assert_eq!(rx.try_recv()?, "Hello world!");
let _ = handler.join();
Ok(())
}