Code Monkey home page Code Monkey logo

io-uring-async's Introduction

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; 
    });
}

io-uring-async's People

Contributors

thomasbarrett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.