lelet

Crates.iolelet
lib.rslelet
version1.2.18
sourcesrc
created_at2020-04-13 01:38:29.80789
updated_at2020-06-17 09:34:16.97628
descriptiongolang like task executor
homepagehttps://github.com/win-t/lelet
repositoryhttps://github.com/win-t/lelet
max_upload_size
id229550
size42,243
Kurnia D Win (win-t)

documentation

https://docs.rs/lelet

README

lelet

A golang like task executor

Crates.io version Download docs.rs docs

Lelet executor

Task executor that inspired by golang runtime.

The executor is running in thread pool, and when it detect blocking call inside a task, it will automatically scale the thread pool.

Because of this feature, it is always safe for you to do blocking operation in a task, you don't need to worry about blocking the entire executor thread.

Installation

With cargo add installed run:

$ cargo add lelet

Example

use std::thread;
use std::time::Duration;

use futures_timer::Delay;

fn main() {
    lelet::spawn(async {
        for _ in 0..10 {
            Delay::new(Duration::from_secs(1)).await;
            println!("Non-blocking Hello World");
        }
    });

    lelet::spawn(async {
        for _ in 0..10 {
            thread::sleep(Duration::from_secs(1));
            println!("Blocking Hello World");
        }
    });

    thread::sleep(Duration::from_secs(11));
}
Commit count: 138

cargo fmt