Skip to content

Commit

Permalink
Merge pull request #29 from vertexclique/new-ring-structure
Browse files Browse the repository at this point in the history
new ring structure
  • Loading branch information
vertexclique authored Jan 20, 2024
2 parents d16da38 + fa0e230 commit ae993e3
Show file tree
Hide file tree
Showing 22 changed files with 324 additions and 321 deletions.
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "nuclei"
version = "0.2.1"
authors = ["Mahmut Bulut <[email protected]>"]
edition = "2018"
edition = "2021"
description = "Proactive IO & runtime system"
keywords = ["io", "async", "uring", "iouring", "proactor"]
categories = ["concurrency", "asynchronous"]
Expand Down Expand Up @@ -31,29 +31,29 @@ autoexamples = false


[features]
default = ["async-exec", "epoll"]
default = ["async-exec", "iouring"]
# Devs should enable these features to use iouring on linux.
#default = ["asyncstd", "iouring"]
epoll = []
iouring = ["iou", "uring-sys"]
iouring = ["rustix-uring", "rustix"]

async-exec = ["async-global-executor"]
tokio03 = ["async-global-executor/tokio03"]
tokio02 = ["async-global-executor/tokio02"]
tokio = ["async-global-executor/tokio"]

[dependencies]
lever = "0.1"
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
socket2 = { version = "0.3.12", features = ["pair", "unix"] }
socket2 = { version = "0.3.19", features = ["pair", "unix"] }
pin-utils = "0.1.0"
once_cell = "1.4.0"
async-global-executor = { version = "2.0", optional = true, features = ["async-io"] }
once_cell = "1.19.0"
os_socketaddr = "0.2.5"
ahash = "0.8.7"
async-global-executor = { version = "2.4", optional = true, features = ["async-io"] }

# Other backends
[target.'cfg(target_os = "linux")'.dependencies]
iou = { version = "0.0.0-ringbahn.1", optional = true }
uring-sys = { version = "0.6.1", optional = true }
rustix = { version = "0.38", optional = true }
rustix-uring = { version = "0.2.0", optional = true }

[target.'cfg(target_family = "unix")'.dependencies]
libc = { version = "0.2" }
Expand Down
5 changes: 5 additions & 0 deletions docs/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "nuclei"
}
}
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
Empty file added docs/.nojekyll
Empty file.
5 changes: 5 additions & 0 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# <img src="https://raw.githubusercontent.com/vertexclique/nuclei/master/img/nuclei-logo.png">
PROACTIVE IO & RUNTIME SYSTEM <small>est. 2019</small>

[![](assets/img/github.svg) GitHub](https://github.com/vertexclique/nuclei)
[![](assets/img/sitemap-solid.svg) What is Nuclei?](https://vertexclique.github.io/nuclei/)
1 change: 1 addition & 0 deletions docs/assets/img/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/img/sitemap-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"hosting": {
"public": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
74 changes: 74 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, shrink-to-fit=no, viewport-fit=cover">
<meta name="description" content="">
<title></title>

<!-- Themes (light + dark) -->
<link rel="stylesheet" media="(prefers-color-scheme: dark)" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css">

<!-- PrismJS theme -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/themes/prism-night-owl.min.css">

<!-- Custom Styles -->
<style>
:root {
--theme-hue: 120;
--theme-color: rgb(106, 25, 205);
/* <a href="https://ibb.co/mhM4z6P"><img src="https://i.ibb.co/DwSQK5j/vibrant-obelisk.png" alt="vibrant-obelisk" border="0"></a> */
--cover-background-color: #00000000;
--cover-background-image: url(https://s13.gifyu.com/images/S0ULN.gif);
--cover-button-background: rgb(118, 198, 251);
--cover-button-border: rgb(118, 198, 251);
--cover-button-border: 1px solid var(--theme-color);
--cover-heading-color: rgb(106, 25, 205);
--cover-heading-font-size: 100px;
--cover-heading-font-size-min: ;
--cover-heading-font-size-max: 500px;
}
</style>
</head>
<body>
<div id="app"></div>

<script>
// Docsify Configuration
window.$docsify = {
// GENERAL
// -----------------------------------------------------------------
name : 'Nuclei - Proactive IO & Runtime system',
repo: 'vertexclique/nuclei',
coverpage : 'coverpage.md',
homepage : 'introduction.md',
loadSidebar: 'sidebar.md',

coverpage: true,
themeable: {
readyTransition : true, // default
responsiveTables: true // default
}
};
</script>

<!-- Required -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/docsify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/docsify-pagination.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/docsify-tabs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-prism@latest/dist/docsify-prism.min.js"></script>

<!-- CDN files for prism -->
<script src="//unpkg.com/[email protected]/prism.js"></script>
<script src="//unpkg.com/[email protected]/components/prism-rust.min.js"></script>
<script src="//unpkg.com/[email protected]/components/prism-toml.min.js"></script>
<script src="//unpkg.com/[email protected]/components/prism-python.min.js"></script>
<script src="//unpkg.com/[email protected]/components/prism-json.min.js"></script>

<!-- Recommended -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/zoom-image.min.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nuclei
1 change: 1 addition & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Quickstart Guide
6 changes: 6 additions & 0 deletions docs/sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- markdownlint-disable-next-line first-line-heading -->
- [Introduction](introduction)
- [Quickstart Guide](quickstart)
- **Internals**
- [Design Principles](designprinciples)
- [Recovery System](recosystem)
3 changes: 2 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2018"
publish = false

[dev-dependencies]
nuclei = { path = "../" }
#nuclei = { path = "../" }
nuclei = { path = "../", default-features = false, features = ["async-exec", "iouring"]}
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
futures-util = "0.3"
anyhow = "1.0.31"
Expand Down
4 changes: 3 additions & 1 deletion examples/fread.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use nuclei::*;
use std::fs::File;
use std::io;
use std::io::{Seek, SeekFrom};

Check warning on line 4 in examples/fread.rs

View workflow job for this annotation

GitHub Actions / stable - x86_64-apple-darwin

unused imports: `SeekFrom`, `Seek`
use std::path::PathBuf;

use futures::AsyncReadExt;
Expand All @@ -10,6 +11,7 @@ fn main() -> io::Result<()> {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("data");
path.push("quark-gluon-plasma");
dbg!(&path);

let fo = File::open(&path).unwrap();
let mut file = Handle::<File>::new(fo).unwrap();
Expand All @@ -19,7 +21,7 @@ fn main() -> io::Result<()> {
});
let x = x?;

// println!("Content: {}", x);
println!("Content: {}", x);
println!("Length of file is {}", x.len());

Ok(())
Expand Down
Binary file added img/nuclei-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/proactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub use super::handle::*;
///
/// Concrete proactor instance
pub struct Proactor(SysProactor);
unsafe impl Send for Proactor {}
unsafe impl Sync for Proactor {}

impl Proactor {
/// Returns a reference to the proactor.
Expand Down
3 changes: 2 additions & 1 deletion src/syscore/bsd/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, RawFd};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{collections::HashMap, os::unix::net::UnixStream, time::Duration};
use ahash::{HashMap, HashMapExt};
use std::{os::unix::net::UnixStream, time::Duration};

macro_rules! syscall {
($fn:ident $args:tt) => {{
Expand Down
3 changes: 2 additions & 1 deletion src/syscore/linux/epoll/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use crate::sys::epoll::*;
use futures::channel::oneshot;
use lever::prelude::*;
use pin_utils::unsafe_pinned;
use ahash::HashMap;
use std::future::Future;
use std::io::{self, Read, Write};
use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{collections::HashMap, fs::File, time::Duration};
use std::{fs::File, time::Duration};

macro_rules! syscall {
($fn:ident $args:tt) => {{
Expand Down
9 changes: 5 additions & 4 deletions src/syscore/linux/iouring/fs/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::mem;
use std::ptr::NonNull;
use std::slice;
use std::task::Poll;
use rustix_uring::types::Statx;

use super::cancellation::Cancellation;

Expand Down Expand Up @@ -99,7 +100,7 @@ impl Buffer {
}
Storage::Statx => {
unsafe fn callback(statx: *mut (), _: usize) {
dealloc(statx as *mut u8, Layout::new::<libc::statx>())
dealloc(statx as *mut u8, Layout::new::<Statx>())
}

self.storage = Storage::Nothing;
Expand All @@ -110,7 +111,7 @@ impl Buffer {
}
}

pub(crate) fn as_statx(&mut self) -> *mut libc::statx {
pub(crate) fn as_statx(&mut self) -> *mut Statx {
match self.storage {
Storage::Statx => self.data.cast().as_ptr(),
Storage::Nothing => self.alloc_statx(),
Expand All @@ -124,7 +125,7 @@ impl Buffer {
unsafe { slice::from_raw_parts_mut(self.data.cast().as_ptr(), self.capacity as usize) }
}

fn alloc_statx(&mut self) -> &mut libc::statx {
fn alloc_statx(&mut self) -> &mut Statx {
self.storage = Storage::Statx;
self.alloc();
unsafe { &mut *self.data.cast().as_ptr() }
Expand All @@ -145,7 +146,7 @@ impl Buffer {
#[inline(always)]
fn layout(&self) -> Option<Layout> {
match self.storage {
Storage::Statx => Some(Layout::new::<libc::statx>()),
Storage::Statx => Some(Layout::new::<Statx>()),
Storage::Buffer => Some(Layout::array::<u8>(self.capacity as usize).unwrap()),
Storage::Nothing => None,
}
Expand Down
Loading

0 comments on commit ae993e3

Please sign in to comment.