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

LIO Control Block.

The basic structure used to issue multiple AIO operations simultaneously.

Implementations

Are no AioCbs contained?

Return the number of individual AioCbs contained.

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

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(Errno::EIO) ||
      err == Err(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

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

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

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Use this to cast from one trait object type to another. Read more

Use this to upcast a trait to one of its supertraits. Read more

Use this to cast from one trait object type to another. This method is more customizable than the dyn_cast method. Here you can also specify the “source” trait from which the cast is defined. This can for example allow using casts from a supertrait of the current trait object. Read more

Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more