Skip to content

Commit

Permalink
rename and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfOne committed Apr 13, 2024
1 parent a69d4bf commit af928fe
Show file tree
Hide file tree
Showing 66 changed files with 321 additions and 311 deletions.
29 changes: 16 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "tokio-uring"
name = "tokio-uring-ooo"
version = "0.4.0"
authors = ["Tokio Contributors <[email protected]>"]
edition = "2018"
authors = [
"Tokio Contributors <[email protected]>",
"Ahmed Mones <[email protected]>",
]
edition = "2021"
readme = "README.md"
license = "MIT"
documentation = "https://docs.rs/tokio-uring/0.4.0/tokio-uring"
repository = "https://github.com/tokio-rs/tokio-uring"
documentation = "https://docs.rs/tokio-uring-ooo"
repository = "https://github.com/ooo-rs/tokio-uring"
homepage = "https://tokio.rs"
description = """
io-uring support for the Tokio asynchronous runtime.
Expand All @@ -17,22 +20,22 @@ keywords = ["async", "fs", "io-uring"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.2", features = ["net", "rt", "sync"] }
tokio = { version = "1", features = ["net", "rt", "sync"] }
slab = "0.4.2"
libc = "0.2.80"
io-uring = "0.6.0"
socket2 = { version = "0.4.4", features = ["all"] }
bytes = { version = "1.0", optional = true }
futures-util = { version = "0.3.26", default-features = false, features = ["std"] }
io-uring-ooo = { version = "0.6", path = "../io-uring-ooo" }
socket2 = { version = "0.5", features = ["all"] }
bytes = { version = "1.6", optional = true }
futures-util = { version = "0.3", default-features = false, features = ["std"] }

[dev-dependencies]
tempfile = "3.2.0"
tokio-test = "0.4.2"
iai = "0.1.1"
criterion = "0.4.0"
criterion = "0.5"
# we use joinset in our tests
tokio = "1.21.2"
nix = "0.26.1"
tokio = "1"
nix = "0.28"

[package.metadata.docs.rs]
all-features = true
Expand Down
10 changes: 5 additions & 5 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tokio-uring = "0.1"

```rust
fn main() {
let rt = tokio_uring::runtime::Runtime::new().unwrap();
let rt = tokio_uring_ooo::runtime::Runtime::new().unwrap();
rt.block_on(async {
// The rest of the application comes here.
});
Expand Down Expand Up @@ -185,7 +185,7 @@ at compile time. The following example demonstrates reading and writing with a
file resource.

```rust
use tokio_uring::buf;
use tokio_uring_ooo::buf;

/// The result of an operation that includes a buffer. The buffer must
/// be returned to the caller when the operation completes successfully
Expand Down Expand Up @@ -254,7 +254,7 @@ let my_pool = BufferPool::builder()
.build();

// Create the runtime
let mut rt = tokio_uring::runtime::Runtime::new()?;
let mut rt = tokio_uring_ooo::runtime::Runtime::new()?;

// Provide the buffer pool to the kernel. This passes
// ownership of the pool to the kernel.
Expand Down Expand Up @@ -525,8 +525,8 @@ within the runtime context at compile time. Attempting to use a tokio-uring
resource from outside of the runtime will result in a panic.

```rust
use tokio_uring::runtime::Runtime;
use tokio_uring::net::TcpListener;
use tokio_uring_ooo::runtime::Runtime;
use tokio_uring_ooo::net::TcpListener;

fn main() {
// Binding a TcpListener does not require access to the runtime.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ tokio-uring = { version = "0.4.0" }
```
In your main.rs:
```rust
use tokio_uring::fs::File;
use tokio_uring_ooo::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio_uring::start(async {
tokio_uring_ooo::start(async {
// Open a file
let file = File::open("hello.txt").await?;

Expand Down
6 changes: 3 additions & 3 deletions benches/criterion/no_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ impl Default for Options {
}

fn run_no_ops(opts: &Options, count: u64) -> Duration {
let mut ring_opts = tokio_uring::uring_builder();
let mut ring_opts = tokio_uring_ooo::uring_builder();
ring_opts.setup_cqsize(opts.cq_size as _);

let mut m = Duration::ZERO;

// Run the required number of iterations
for _ in 0..count {
m += tokio_uring::builder()
m += tokio_uring_ooo::builder()
.entries(opts.sq_size as _)
.uring_builder(&ring_opts)
.start(async move {
let mut js = JoinSet::new();

for _ in 0..opts.iterations {
js.spawn_local(tokio_uring::no_op());
js.spawn_local(tokio_uring_ooo::no_op());
}

let start = Instant::now();
Expand Down
10 changes: 5 additions & 5 deletions benches/lai/no_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ impl Default for Options {

fn runtime_only() -> Result<(), Box<dyn std::error::Error>> {
let opts = Options::default();
let mut ring_opts = tokio_uring::uring_builder();
let mut ring_opts = tokio_uring_ooo::uring_builder();
ring_opts.setup_cqsize(opts.cq_size as _);

tokio_uring::builder()
tokio_uring_ooo::builder()
.entries(opts.sq_size as _)
.uring_builder(&ring_opts)
.start(async move { black_box(Ok(())) })
}

fn run_no_ops(opts: Options) -> Result<(), Box<dyn std::error::Error>> {
let mut ring_opts = tokio_uring::uring_builder();
let mut ring_opts = tokio_uring_ooo::uring_builder();
ring_opts.setup_cqsize(opts.cq_size as _);

tokio_uring::builder()
tokio_uring_ooo::builder()
.entries(opts.sq_size as _)
.uring_builder(&ring_opts)
.start(async move {
let mut js = JoinSet::new();

for _ in 0..opts.iterations {
js.spawn_local(tokio_uring::no_op());
js.spawn_local(tokio_uring_ooo::no_op());
}

while let Some(res) = js.join_next().await {
Expand Down
4 changes: 2 additions & 2 deletions examples/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
{env, io},
};

use tokio_uring::fs::File;
use tokio_uring_ooo::fs::File;

fn main() {
// The file to `cat` is passed as a CLI argument
Expand All @@ -19,7 +19,7 @@ fn main() {
let out = io::stdout();
let mut out = out.lock();

tokio_uring::start(async {
tokio_uring_ooo::start(async {
// Open the file without blocking
let file = File::open(path).await.unwrap();
let mut buf = vec![0; 16 * 1_024];
Expand Down
6 changes: 3 additions & 3 deletions examples/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::env;

use tokio_uring::{fs::File, net::TcpListener};
use tokio_uring_ooo::{fs::File, net::TcpListener};

fn main() {
// The file to serve over TCP is passed as a CLI argument
Expand All @@ -14,7 +14,7 @@ fn main() {
panic!("no path specified");
}

tokio_uring::start(async {
tokio_uring_ooo::start(async {
// Start a TCP listener
let listener = TcpListener::bind("0.0.0.0:8080".parse().unwrap()).unwrap();

Expand All @@ -24,7 +24,7 @@ fn main() {
let path = args[1].clone();

// Spawn a task to send the file back to the socket
tokio_uring::spawn(async move {
tokio_uring_ooo::spawn(async move {
// Open the file without blocking
let file = File::open(path).await.unwrap();
let mut buf = vec![0; 16 * 1_024];
Expand Down
8 changes: 4 additions & 4 deletions examples/tcp_listener.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, net::SocketAddr};

use tokio_uring::net::TcpListener;
use tokio_uring_ooo::net::TcpListener;

fn main() {
let args: Vec<_> = env::args().collect();
Expand All @@ -12,17 +12,17 @@ fn main() {
};
let socket_addr: SocketAddr = socket_addr.parse().unwrap();

tokio_uring::start(async {
tokio_uring_ooo::start(async {
let listener = TcpListener::bind(socket_addr).unwrap();

println!("Listening on {}", listener.local_addr().unwrap());

loop {
let (stream, socket_addr) = listener.accept().await.unwrap();
tokio_uring::spawn(async move {
tokio_uring_ooo::spawn(async move {
// implement ping-pong loop

use tokio_uring::buf::BoundedBuf; // for slice()
use tokio_uring_ooo::buf::BoundedBuf; // for slice()

println!("{} connected", socket_addr);
let mut n = 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/tcp_listener_fixed_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::{env, iter, net::SocketAddr};

use tokio_uring::{
use tokio_uring_ooo::{
buf::{fixed::FixedBufRegistry, BoundedBuf, IoBufMut},
net::{TcpListener, TcpStream},
}; // BoundedBuf for slice method
Expand All @@ -21,7 +21,7 @@ fn main() {
};
let socket_addr: SocketAddr = socket_addr.parse().unwrap();

tokio_uring::start(accept_loop(socket_addr));
tokio_uring_ooo::start(accept_loop(socket_addr));
}

// Bind to address and accept connections, spawning an echo handler for each connection.
Expand All @@ -43,7 +43,7 @@ async fn accept_loop(listen_addr: SocketAddr) {
loop {
let (stream, peer) = listener.accept().await.unwrap();

tokio_uring::spawn(echo_handler(stream, peer, registry.clone()));
tokio_uring_ooo::spawn(echo_handler(stream, peer, registry.clone()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/tcp_stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, net::SocketAddr};

use tokio_uring::net::TcpStream;
use tokio_uring_ooo::net::TcpStream;

fn main() {
let args: Vec<_> = env::args().collect();
Expand All @@ -11,7 +11,7 @@ fn main() {

let socket_addr: SocketAddr = args[1].parse().unwrap();

tokio_uring::start(async {
tokio_uring_ooo::start(async {
let stream = TcpStream::connect(socket_addr).await.unwrap();
let buf = vec![1u8; 128];

Expand Down
18 changes: 9 additions & 9 deletions examples/test_create_dir_all.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io;
use std::path::Path;
use tokio_uring::fs;
use tokio_uring_ooo::fs;

fn tests() -> std::slice::Iter<'static, Expected<'static>> {
[
Expand Down Expand Up @@ -171,12 +171,12 @@ async fn main1() -> io::Result<()> {
}

async fn statx<P: AsRef<Path>>(path: P) -> io::Result<()> {
let _statx = tokio_uring::fs::statx(path).await?;
let _statx = tokio_uring_ooo::fs::statx(path).await?;
Ok(())
}

async fn statx_builder<P: AsRef<Path>>(path: P) -> io::Result<()> {
let _statx = tokio_uring::fs::StatxBuilder::new()
let _statx = tokio_uring_ooo::fs::StatxBuilder::new()
.pathname(path)?
.statx()
.await?;
Expand All @@ -187,7 +187,7 @@ async fn statx_builder2<P: AsRef<Path>>(dir_path: P, rel_path: P) -> io::Result<
// This shows the power of combining an open file, presumably a directory, and the relative
// path to have the statx operation return the meta data for the child of the opened directory
// descriptor.
let f = tokio_uring::fs::File::open(dir_path).await?;
let f = tokio_uring_ooo::fs::File::open(dir_path).await?;

// Fetch file metadata
let res = f.statx_builder().pathname(rel_path)?.statx().await;
Expand All @@ -199,7 +199,7 @@ async fn statx_builder2<P: AsRef<Path>>(dir_path: P, rel_path: P) -> io::Result<
}

async fn matches_mode<P: AsRef<Path>>(path: P, want_mode: u16) -> io::Result<()> {
let statx = tokio_uring::fs::StatxBuilder::new()
let statx = tokio_uring_ooo::fs::StatxBuilder::new()
.mask(libc::STATX_MODE)
.pathname(path)?
.statx()
Expand All @@ -216,7 +216,7 @@ async fn matches_mode<P: AsRef<Path>>(path: P, want_mode: u16) -> io::Result<()>
}

async fn touch_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
let file = tokio_uring::fs::OpenOptions::new()
let file = tokio_uring_ooo::fs::OpenOptions::new()
.append(true)
.create(true)
.open(path)
Expand All @@ -226,7 +226,7 @@ async fn touch_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
}

async fn is_regfile<P: AsRef<Path>>(path: P) -> io::Result<()> {
let (_is_dir, is_regfile) = tokio_uring::fs::is_dir_regfile(path).await;
let (_is_dir, is_regfile) = tokio_uring_ooo::fs::is_dir_regfile(path).await;

if is_regfile {
Ok(())
Expand All @@ -239,7 +239,7 @@ async fn is_regfile<P: AsRef<Path>>(path: P) -> io::Result<()> {
}

async fn is_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
let (is_dir, _is_regfile) = tokio_uring::fs::is_dir_regfile(path).await;
let (is_dir, _is_regfile) = tokio_uring_ooo::fs::is_dir_regfile(path).await;

if is_dir {
Ok(())
Expand All @@ -252,7 +252,7 @@ async fn is_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
}

fn main() {
tokio_uring::start(async {
tokio_uring_ooo::start(async {
if let Err(e) = main1().await {
println!("error: {}", e);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/udp_socket.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{env, net::SocketAddr};
use tokio_uring::net::UdpSocket;
use tokio_uring_ooo::net::UdpSocket;

fn main() {
let args: Vec<_> = env::args().collect();
Expand All @@ -10,7 +10,7 @@ fn main() {

let socket_addr: SocketAddr = args[1].parse().unwrap();

tokio_uring::start(async {
tokio_uring_ooo::start(async {
let socket = UdpSocket::bind(socket_addr).await.unwrap();

let buf = vec![0u8; 128];
Expand Down
6 changes: 3 additions & 3 deletions examples/unix_listener.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::env;

use tokio_uring::net::UnixListener;
use tokio_uring_ooo::net::UnixListener;

fn main() {
let args: Vec<_> = env::args().collect();
Expand All @@ -11,13 +11,13 @@ fn main() {

let socket_addr: String = args[1].clone();

tokio_uring::start(async {
tokio_uring_ooo::start(async {
let listener = UnixListener::bind(&socket_addr).unwrap();

loop {
let stream = listener.accept().await.unwrap();
let socket_addr = socket_addr.clone();
tokio_uring::spawn(async move {
tokio_uring_ooo::spawn(async move {
let buf = vec![1u8; 128];

let (result, buf) = stream.write(buf).submit().await;
Expand Down
Loading

0 comments on commit af928fe

Please sign in to comment.