Struct nix::sys::aio::LioCb[][src]

pub struct LioCb<'a> { /* fields omitted */ }
Expand description

LIO Control Block.

The basic structure used to issue multiple AIO operations simultaneously.

Implementations

impl<'a> LioCb<'a>[src]

pub fn is_empty(&self) -> bool[src]

pub fn len(&self) -> usize[src]

Return the number of individual AioCbs contained.

pub fn listio(&mut self, mode: LioMode, sigev_notify: SigevNotify) -> Result<()>[src]

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 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 liocb = LioCbBuilder::with_capacity(1)
    .emplace_slice(
        f.as_raw_fd(),
        2,   //offset
        WBUF,
        0,   //priority
        SigevNotify::SigevNone,
        LioOpcode::LIO_WRITE
    ).finish();
liocb.listio(LioMode::LIO_WAIT,
             SigevNotify::SigevNone).unwrap();
assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len());

References

lio_listio

pub fn listio_resubmit(
    &mut self,
    mode: LioMode,
    sigev_notify: SigevNotify
) -> Result<()>
[src]

Resubmits any incomplete operations with lio_listio.

Sometimes, due to system resource limitations, an lio_listio call will return EIO, or EAGAIN. Or, if a signal is received, it may return EINTR. In any of these cases, only a subset of its constituent operations will actually have been initiated. listio_resubmit will resubmit any operations that are still uninitiated.

After calling listio_resubmit, results should be collected by LioCb::aio_return.

Examples

const WBUF: &[u8] = b"abcdef123456";
let mut f = tempfile().unwrap();
let mut liocb = LioCbBuilder::with_capacity(1)
    .emplace_slice(
        f.as_raw_fd(),
        2,   //offset
        WBUF,
        0,   //priority
        SigevNotify::SigevNone,
        LioOpcode::LIO_WRITE
    ).finish();
let mut err = liocb.listio(LioMode::LIO_WAIT, SigevNotify::SigevNone);
while err == Err(Error::Sys(Errno::EIO)) ||
      err == Err(Error::Sys(Errno::EAGAIN)) {
    thread::sleep(time::Duration::from_millis(10));
    err = liocb.listio_resubmit(LioMode::LIO_WAIT, SigevNotify::SigevNone);
}
assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len());

References

lio_listio

pub fn aio_return(&mut self, i: usize) -> Result<isize>[src]

Collect final status for an individual AioCb submitted as part of an LioCb.

This is just like AioCb::aio_return, except it takes into account operations that were restarted by LioCb::listio_resubmit

pub fn error(&mut self, i: usize) -> Result<()>[src]

Retrieve error status of an individual AioCb submitted as part of an LioCb.

This is just like AioCb::error, except it takes into account operations that were restarted by LioCb::listio_resubmit

Trait Implementations

impl<'a> Debug for LioCb<'a>[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a> Send for LioCb<'a>[src]

LioCb can’t automatically impl Send and Sync just because of the raw pointers in list. But that’s stupid. There’s no reason that raw pointers should automatically be non-Send

impl<'a> Sync for LioCb<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for LioCb<'a>

impl<'a> Unpin for LioCb<'a>

impl<'a> UnwindSafe for LioCb<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.