microasync-rt 0.2.1

A runtime for the very small async runner
Documentation
  • Coverage
  • 28.13%
    9 out of 32 items documented0 out of 12 items with examples
  • Size
  • Source code size: 25.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.27 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • TudbuT/microasync-rt
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TudbuT

microasync-runtime

MicroAsync (GitHub) does not have many features, no IO support, no proper runtime. MicroAsync-Runtime provides such things:

  • A small runtime with the ability to add tasks (no_std supported)
  • A small timer
  • AsyncIO for Files, TCP, and UDP

QueuedRuntime

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));
}

Examples

There are a bunch of examples in examples/ - feel free to check those out!

Compatibility

MicroAsync-Runtime is compatible with async-core.