Crates.io | open-coroutine-core |
lib.rs | open-coroutine-core |
version | |
source | src |
created_at | 2023-02-14 08:38:09.907056 |
updated_at | 2025-01-11 14:03:01.334986 |
description | The open-coroutine is a simple, efficient and generic coroutine library. |
homepage | |
repository | https://github.com/acl-dev/open-coroutine |
max_upload_size | |
id | 784717 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
The open-coroutine
is a simple, efficient and generic stackfull-coroutine library, you can use this as a performance
replacement for IO thread pools, see why better.
English | δΈζ
not supported in windows
): even if the coroutine enters a dead loop, it can still be seized,
see example;only in linux
): supports and is compatible with io_uring in terms of local file IO and network IO. If
it's not supported on your system, it will fall back to non-blocking IO;tokio/async-std/smol/...
;graph TD
subgraph ApplicationFramework
Tower
Actix-Web
Rocket
warp
axum
end
subgraph MessageQueue
RocketMQ
Pulsar
end
subgraph RemoteProcedureCall
Dubbo
Tonic
gRPC-rs
Volo
end
subgraph Database
MySQL
Oracle
end
subgraph NetworkFramework
Tokio
monoio
async-std
smol
end
subgraph open-coroutine-architecture
subgraph core
Preemptive
ScalableStack
WorkSteal
Priority
end
subgraph hook
HookSyscall
end
subgraph macros
open-coroutine::main
end
subgraph open-coroutine
end
hook -->|depends on| core
open-coroutine -->|link| hook
open-coroutine -->|depends on| macros
end
subgraph OperationSystem
Linux
macOS
Windows
end
ApplicationFramework -->|maybe depends on| RemoteProcedureCall
ApplicationFramework -->|maybe depends on| MessageQueue
ApplicationFramework -->|maybe depends on| Database
MessageQueue -->|depends on| NetworkFramework
RemoteProcedureCall -->|depends on| NetworkFramework
NetworkFramework -->|runs on| OperationSystem
NetworkFramework -->|can depends on| open-coroutine-architecture
Database -->|runs on| OperationSystem
open-coroutine-architecture -->|runs on| OperationSystem
[dependencies]
# check https://crates.io/crates/open-coroutine
open-coroutine = "x.y.z"
open_coroutine::main
macro#[open_coroutine::main]
fn main() {
//......
}
#[open_coroutine::main]
fn main() {
_ = open_coroutine::task!(|param| {
assert_eq!(param, "param");
}, "param");
}
#[open_coroutine::main]
fn main() {
_ = open_coroutine::task!(|param| {
assert_eq!(param, "param");
}, "param", 1/*the smaller the value, the higher the priority*/);
}
#[open_coroutine::main]
fn main() {
let task = open_coroutine::task!(|param| {
assert_eq!(param, "param");
}, "param", 1);
task.timeout_join(std::time::Duration::from_secs(1)).expect("timeout");
}
#[open_coroutine::main]
fn main() {
_ = open_coroutine::task!(|_| {
fn recurse(i: u32, p: &mut [u8; 10240]) {
open_coroutine::maybe_grow!(|| {
// Ensure the stack allocation isn't optimized away.
unsafe { _ = std::ptr::read_volatile(&p) };
if i > 0 {
recurse(i - 1, &mut [0; 10240]);
}
})
.expect("allocate stack failed")
}
println!("[task] launched");
// Use ~500KB of stack.
recurse(50, &mut [0; 10240]);
}, ());
}
This crate was inspired by the following projects:
Thanks to those who have provided assistance: