nix::sys::aio

Function aio_suspend

Source
pub fn aio_suspend(
    list: &[&dyn AsRef<aiocb>],
    timeout: Option<TimeSpec>,
) -> Result<()>
Expand description

Suspends the calling process until at least one of the specified operations have completed, a signal is delivered, or the timeout has passed.

If timeout is None, aio_suspend will block indefinitely.

§Examples

Use aio_suspend to block until an aio operation completes.

const WBUF: &[u8] = b"abcdef123456";
let mut f = tempfile().unwrap();
let mut aiocb = Box::pin(AioWrite::new(f.as_raw_fd(),
    2,   //offset
    WBUF,
    0,   //priority
    SigevNotify::SigevNone));
aiocb.as_mut().submit().unwrap();
aio_suspend(&[&*aiocb], None).expect("aio_suspend failed");
assert_eq!(aiocb.as_mut().aio_return().unwrap() as usize, WBUF.len());

§References

aio_suspend