Function nix::sys::aio::aio_cancel_all

source ·
pub fn aio_cancel_all<F: AsFd>(fd: F) -> Result<AioCancelStat>
Expand description

Cancels outstanding AIO requests for a given file descriptor.

§Examples

Issue an aio operation, then cancel all outstanding operations on that file descriptor.

let wbuf = b"CDEF";
let mut f = tempfile().unwrap();
let mut aiocb = Box::pin(AioWrite::new(f.as_fd(),
    2,   //offset
    &wbuf[..],
    0,   //priority
    SigevNotify::SigevNone));
aiocb.as_mut().submit().unwrap();
let cs = aio_cancel_all(f.as_fd()).unwrap();
if cs == AioCancelStat::AioNotCanceled {
    while (aiocb.as_mut().error() == Err(Errno::EINPROGRESS)) {
        thread::sleep(time::Duration::from_millis(10));
    }
}
// Must call `aio_return`, but ignore the result
let _ = aiocb.as_mut().aio_return();

§References

aio_cancel