Function nix::sys::aio::lio_listio [] [src]

pub fn lio_listio(
    mode: LioMode,
    list: &[&mut AioCb],
    sigev_notify: SigevNotify
) -> Result<()>

Submits multiple asynchronous I/O requests with a single system call.

They are not guaranteed to complete atomically, and the order in which the requests are carried out is not specified. Reads, writes, and fsyncs may be freely mixed.

This function is useful for reducing the context-switch overhead of submitting many AIO operations. It can also be used with LioMode::LIO_WAIT to block on the result of several independent operations. Used that way, it is often useful in programs that otherwise make little use of AIO.

Examples

Use lio_listio to submit an aio operation and wait for its completion. In this case, there is no need to use aio_suspend to wait or AioCb#error to poll.

const WBUF: &[u8] = b"abcdef123456";
let mut f = tempfile().unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
    2,   //offset
    WBUF,
    0,   //priority
    SigevNotify::SigevNone,
    LioOpcode::LIO_WRITE);
lio_listio(LioMode::LIO_WAIT,
           &[&mut aiocb],
           SigevNotify::SigevNone).unwrap();
assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len());

References

lio_listio