24 releases

0.8.4 Jul 16, 2022
0.8.2 Feb 27, 2022
0.8.0 Mar 30, 2021
0.7.0 Mar 25, 2020
0.5.3 Nov 15, 2019

#355 in WebAssembly

Download history 1/week @ 2024-01-14 3/week @ 2024-01-21 13/week @ 2024-01-28 1/week @ 2024-02-04 20/week @ 2024-02-18 63/week @ 2024-02-25 9/week @ 2024-03-03 37/week @ 2024-03-10 17/week @ 2024-03-17 54/week @ 2024-03-31 9/week @ 2024-04-07 7/week @ 2024-04-14 28/week @ 2024-04-21 5/week @ 2024-04-28

57 downloads per month
Used in ockam_node_no_std

MIT/Apache

12KB
78 lines

executor

docs.rs docs

[dependencies]
executor = "0.8"

Features

  • #![no_std] + alloc
  • simple enough to learn from! (~ 100 lines)
  • works with WebAssembly

WebAssembly

use web::*;

#[no_mangle]
fn main() {
    executor::run(async {
        loop {
            set_inner_html(DOM_BODY, "⏰ tic");
            sleep(1000).await;
            set_inner_html(DOM_BODY, "⏰ tock");
            sleep(1000).await;
        }
    });
}

See this working here.

CLI

Even async-std can be used if you add something to stop it from exiting too early.

use async_std::task::sleep;
use std::time::Duration;

fn main() {
    let complete = std::sync::Arc::new(core::sync::atomic::AtomicBool::new(false));
    let ender = complete.clone();
    executor::run(async move {
        println!("hello");
        sleep(Duration::from_secs(1)).await;
        println!("world!");
        ender.store(true, core::sync::atomic::Ordering::Release);
    });
    while !complete.load(core::sync::atomic::Ordering::Acquire) {}
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in executor by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~160KB