Function ev3dev_lang_rust::wait::wait
source · pub fn wait<F>(fd: RawFd, cond: F, timeout: Option<Duration>) -> boolwhere
F: Fn() -> bool,Expand description
Wait for until a condition cond is true or the timeout is reached.
If the timeout is None it will wait an infinite time.
The condition is checked when the file has changed.
Arguments
file- Listen to changes in this filecond- Condition that should become truetimeout- Maximal timeout to wait for the condition or file changes
Example
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::time::Duration;
use ev3dev_lang_rust::wait;
if let Ok(file) = File::open("...") {
let cond = || {
// ...
true
};
let timeout = Duration::from_millis(2000);
wait::wait(file.as_raw_fd(), cond, Some(timeout));
}