13个版本
0.3.7 | 2022年8月8日 |
---|---|
0.3.6 | 2022年4月24日 |
0.3.3 | 2021年7月27日 |
0.3.2 | 2021年3月26日 |
0.1.2 | 2021年3月23日 |
在异步类别中排名2216
每月下载量99次
被9个 crate 使用(3个直接使用)
12KB
152 行
Task-Stream
task-stream是一个全局任务执行器,可以在no_std
中运行。
用法
spawn
async fn async_task() {
println!("async_task.");
}
task_stream::spawn(async_task());
executor
不使用异步执行器
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();
}
});
}
依赖项
~0.7–1MB
~18K SLoC