Skip to content
ppmpreethamPublic

About

a simple cross platform kernel I/O reactor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polyring

A high perf generalized mem safe io_uring Reactor Core

Supported Platforms

  • Linux: Full, zero-copy support via io_uring.
  • Windows: Currently stubbed (IOCP loop awaiting implementation).

Quick Start

Below is a complete example of instantiating the reactor, registering decoupled memory, and executing a background file write.

use std::fs::File;
use std::sync::Arc;
use polyring::{Ring, ShutdownPolicy};

fn main() -> std::io::Result<()> {
    let mut ring = Ring::new(128, 256)?;
    let data = b"Hello, asynchronous world!".to_vec().into_boxed_slice();
    let buffer_token = ring.buf_registry.as_mut().unwrap().register(data)?;
    let file = Arc::new(File::create("output.txt")?);
    let write_token = ring.write(file, buffer_token, 0)?;
    let _submitted_count = ring.submit()?;
    let completion = ring.wait()?;
    match completion.status {
        Ok(payload) => println!("Success! Transferred: {:?}", payload),
        Err(e) => eprintln!("I/O Failure: {}", e),
    }
    ring.shutdown(ShutdownPolicy::DrainAll)?;
    Ok(())
}

API

BufferRegistry

Manages the memory you intend to share with the kernel.

  • register(box): Hands ownership to the registry, returns a safe token.
  • reclaim(token): Takes ownership back to user space once the kernel is done.

Polyring Methods

  • read() / write(): Stage operations into the local queue.
  • cancel(token): Stage an AsyncCancel signal targeting a previously submitted operation.
  • submit(): Transactionally flushes the staged queue to the kernel's Submission Queue (SQ).
  • wait(): Blocks until a Completion Queue Event (CQE) is ready, seamlessly advancing the operation's internal state machine.

About

a simple cross platform kernel I/O reactor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages