Module chipset_device::io::deferred
source · Expand description
Support for deferred IO, used when an IO can’t be completed synchronously.
Example:
struct Device {
deferred: Option<DeferredRead>,
}
impl Device {
fn read_handler(&mut self, data: &mut [u8]) -> IoResult {
// Defer this request to later.
let (deferred, token) = defer_read();
IoResult::Defer(token.into())
}
fn poll_device(&mut self, _cx: &mut Context<'_>) {
// The data is now available, complete the request.
if let Some(deferred) = self.deferred.take() {
deferred.complete(&[123]);
}
}
}
Structs§
- A deferred read operation.
- Token to return in
IoResult::Defer
for deferred IOs. - A deferred write operation.
Functions§
- Creates a deferred IO read operation.
- Creates a deferred IO write operation.