async-runtime 0.3.2

A priority-aware native async runtime for the smol ecosystem with host-driven local domains
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The smallest complete general-runtime program.
//!
//! Run with `cargo run --example 01_quick_start`.
//! Use `Runtime` for `Send + 'static` work that may run on a worker thread.

use async_runtime::{Priority, RuntimeBuilder};
use futures_lite::future;
use std::num::NonZeroUsize;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let runtime = RuntimeBuilder::new(NonZeroUsize::new(1).expect("non-zero")).build()?;
    let task = runtime.spawn(Priority::High, async { "Hello from high priority work" })?;

    println!("{}", future::block_on(task));
    runtime.shutdown_graceful()?;
    Ok(())
}