2 releases

0.1.1 Sep 5, 2024
0.1.0 Aug 14, 2024

#1337 in Network programming

Download history 30/week @ 2024-08-21 39/week @ 2024-08-28 153/week @ 2024-09-04 46/week @ 2024-09-11 38/week @ 2024-09-18 43/week @ 2024-09-25 15/week @ 2024-10-02 15/week @ 2024-10-09 12/week @ 2024-10-16 8/week @ 2024-10-23 13/week @ 2024-10-30 9/week @ 2024-11-06 2/week @ 2024-11-13 9/week @ 2024-11-20 16/week @ 2024-11-27 26/week @ 2024-12-04

53 downloads per month
Used in buffet

MIT/Apache

17KB
327 lines

luring

luring is originally a fork of https://github.com/thomasbarrett/io-uring-async

It's the io_uring engine for loona

The original README follows.

IoUringAsync

IoUringAsync is a thin async compatability layer over the commonly used io-uring library that makes it easier to use with the Tokio runtime.

Similar Projects

This project is heavily inspired by the tokio-uring project. Unlike tokio-uring, IoUringAsync is not its own runtime. Instead, it is a lightweight collection of mostly runtime-agnostic future.

Limitations

Currently, this project does not support multishot io_uring operations.

Complete Control over SQE submission.

let sqe = opcode::Write(...).build();
let fut = uring.push(sqe);
uring.submit();
let cqe = fut.await;

Example

use std::rc::Rc;
use io_uring::{squeue, cqueue, opcode};
use io_uring_async::IoUringAsync;
use send_wrapper::SendWrapper;

fn main() {
    let uring = IoUringAsync::new(8).unwrap();
    let uring = Rc::new(uring);

    // Create a new current_thread runtime that submits all outstanding submission queue
    // entries as soon as the executor goes idle.
    let uring_clone = SendWrapper::new(uring.clone());
    let runtime = tokio::runtime::Builder::new_current_thread().
        on_thread_park(move || { uring_clone.submit().unwrap(); }).
        enable_all().
        build().unwrap();

    runtime.block_on(async move {
        tokio::task::LocalSet::new().run_until(async {
            // Spawn a task that waits for the io_uring to become readable and handles completion
            // queue entries accordingly.
            tokio::task::spawn_local(IoUringAsync::listen(uring.clone()));

            let cqe = uring.push(Nop::new().build()).await;
            assert!(cqe.result() >= 0, "nop error: {}", cqe.result());
        }).await;
    });
}

Dependencies

~3–11MB
~103K SLoC