mirror of https://github.com/stjepang/smol
Fix Linux examples
This commit is contained in:
parent
bf154f249b
commit
cb2fcede56
|
@ -11,8 +11,9 @@ fn main() -> std::io::Result<()> {
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
use async_io::Async;
|
||||||
|
use blocking::block_on;
|
||||||
use inotify::{EventMask, Inotify, WatchMask};
|
use inotify::{EventMask, Inotify, WatchMask};
|
||||||
use smol::Async;
|
|
||||||
|
|
||||||
type Event = (OsString, EventMask);
|
type Event = (OsString, EventMask);
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ fn main() -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
smol::run(async {
|
block_on(async {
|
||||||
// Watch events in the current directory.
|
// Watch events in the current directory.
|
||||||
let mut inotify = Async::new(Inotify::init()?)?;
|
let mut inotify = Async::new(Inotify::init()?)?;
|
||||||
inotify.get_mut().add_watch(".", WatchMask::ALL_EVENTS)?;
|
inotify.get_mut().add_watch(".", WatchMask::ALL_EVENTS)?;
|
||||||
|
|
|
@ -12,7 +12,8 @@ fn main() -> std::io::Result<()> {
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use smol::Async;
|
use async_io::Async;
|
||||||
|
use blocking::block_on;
|
||||||
use timerfd::{SetTimeFlags, TimerFd, TimerState};
|
use timerfd::{SetTimeFlags, TimerFd, TimerState};
|
||||||
|
|
||||||
/// Converts a [`nix::Error`] into [`std::io::Error`].
|
/// Converts a [`nix::Error`] into [`std::io::Error`].
|
||||||
|
@ -36,7 +37,7 @@ fn main() -> std::io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
smol::run(async {
|
block_on(async {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
println!("Sleeping...");
|
println!("Sleeping...");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue