kbio, the Async IO Framework based on io_uring, is used in KuiBaDB to implement async io.
Features
- Support multi-threading concurrent task submission.
- Very Fast.
- Implement AsyncRead/AsyncWrite trait introduced in tokio.
Examples
async fn read_body(stream: &mut Sock, content: &mut Vec<u8>) -> io::Result<()> {
let len = stream.read_u32().await?;
let msglen = len as usize - size_of::<u32>();
content.reserve(msglen);
unsafe {
content.set_len(msglen);
}
stream.read_exact(content.as_mut_slice()).await?;
return Ok(());
}
See examples in examples/ and the source code of KuiBaDB for more details.