[][src]Function ev3dev_lang_rust::wait::wait

pub fn wait<F>(fd: RawFd, cond: F, timeout: Option<Duration>) -> bool where
    F: Fn() -> bool

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 file
  • cond - Condition that should become true
  • timeout - Maximal timeout to wait for the condition or file changes

Example

let fd = File::open(...).unwrap().as_raw_fd();
let cond = || {
    ...
    true
};
let timeout = Duration::from_millis(2000);

wait::wait(fd, cond, timeout);