Crates.io | task-stream |
lib.rs | task-stream |
version | 0.3.7 |
source | src |
created_at | 2021-03-22 13:58:02.652094 |
updated_at | 2022-08-08 03:22:54.644684 |
description | a global task executor, run in `no_std`. |
homepage | https://blog.crise.cn |
repository | https://github.com/rise0chen/task-stream.git |
max_upload_size | |
id | 372149 |
size | 34,181 |
task-stream is a global task executor, can run in no_std
.
async fn async_task() {
println!("async_task.");
}
task_stream::spawn(async_task());
use core::time::Duration;
use std::thread;
fn main() {
let stream = task_stream::stream();
loop {
while let Some(task) = stream.get_task() {
task.run();
}
thread::sleep(Duration::from_millis(100));
}
}
use async_std::prelude::*;
use async_std::task;
fn main() {
task::spawn(async {
let mut stream = task_stream::stream();
while let Some(task) = stream.next().await {
task.run();
}
});
}