Crates.io | executor |
lib.rs | executor |
version | 0.8.4 |
source | src |
created_at | 2019-10-08 22:47:40.599663 |
updated_at | 2022-07-16 18:30:05.761821 |
description | A minimalistic async/await executor |
homepage | |
repository | https://www.github.com/richardanaya/executor |
max_upload_size | |
id | 170935 |
size | 34,317 |
[dependencies]
executor = "0.8"
#![no_std]
+ alloc
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.
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) {}
}
This project is licensed under either of
at your option.
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.