Crates.io | microasync-rt |
lib.rs | microasync-rt |
version | 0.2.1 |
source | src |
created_at | 2023-01-11 23:14:08.746367 |
updated_at | 2023-01-12 00:36:29.488877 |
description | A runtime for the very small async runner |
homepage | |
repository | https://github.com/tudbut/microasync-rt |
max_upload_size | |
id | 756755 |
size | 25,626 |
MicroAsync (GitHub) does not have many features, no IO support, no proper runtime. MicroAsync-Runtime provides such things:
no_std
supported)QueuedRuntime is a very small async runtime with support for adding more tasks while it is running. New tasks MUST only be added from within tasks already running on it OR before it is awaited!
use microasync::sync;
use microasync_rt::{QueuedRuntime, wait_ms};
fn main() {
let mut runtime = QueuedRuntime::new();
for _ in 0..50 {
runtime.push(print_something_after_ms(2000));
}
sync(runtime);
}
async fn print_something_after_ms(ms: u64) {
wait_ms(ms).await;
println!("something! :D");
}
use microasync::sync;
use microasync_rt::{QueuedRuntime, wait_ms, get_current_runtime};
fn main() {
sync(QueuedRuntime::new_with(print_something_after_ms(0)));
}
async fn print_something_after_ms(ms: u64) {
wait_ms(ms).await;
println!("something after {ms}ms! :D");
get_current_runtime().await.push(print_something_after_ms(ms + 1));
}
There are a bunch of examples in examples/ - feel free to check those out!
MicroAsync-Runtime is compatible with async-core.