1 stable release

1.2.18 Jun 17, 2020
1.2.17 Jun 15, 2020
1.2.7 May 31, 2020
1.1.13 Apr 30, 2020

#453 in Asynchronous

Download history 77/week @ 2021-01-13 1/week @ 2021-02-03 965/week @ 2021-02-10 154/week @ 2021-02-17 75/week @ 2021-02-24 52/week @ 2021-03-03 2/week @ 2021-03-17 156/week @ 2021-03-24 229/week @ 2021-03-31 77/week @ 2021-04-07 114/week @ 2021-04-14 57/week @ 2021-04-21 77/week @ 2021-04-28

451 downloads per month

GPL-3.0+

39KB
921 lines

lelet

A golang like task executor

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

Dependencies

~795KB
~13K SLoC