Skip to content

rise0chen/task-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task-Stream

task-stream is a global task executor, can run in no_std.

Usage

spawn

async fn async_task() {
    println!("async_task.");
}
task_stream::spawn(async_task());

executor

without async 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 executor

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();
        }
    });
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages