5 releases

0.0.5 Feb 23, 2024
0.0.4 Feb 11, 2024
0.0.3 Nov 28, 2023
0.0.2 Nov 22, 2023
0.0.1 Nov 19, 2023

#508 in Asynchronous

Download history 20/week @ 2023-12-23 7/week @ 2023-12-30 11/week @ 2024-01-06 8/week @ 2024-01-13 13/week @ 2024-01-20 19/week @ 2024-01-27 9/week @ 2024-02-03 18/week @ 2024-02-10 111/week @ 2024-02-17 179/week @ 2024-02-24 34/week @ 2024-03-02 35/week @ 2024-03-09 36/week @ 2024-03-16 12/week @ 2024-03-23 40/week @ 2024-03-30 19/week @ 2024-04-06

115 downloads per month


769 lines

Build Status codecov Lines of Code

Pūteketeke: Rust Async Runtime

This crate takes smol and builds upon it to provide a more intuitive and complete runtime for async Rust programs. This is what you might end up with if you started with smol, added a threadpool and made the API easier to use.

Here's a hello world program.

// Create an executor with four threads.
use puteketeke::{AsyncTask, Executor};
use futures_lite::future;

let executor = Executor::new(4);

let task = executor
    .create_task(async { println!("Hello world") })

// Note that we need to start the task, otherwise it will never run.

Check out the documentation for usage information.

Purpose — or; do we need another runtime?

For me the answer to that question is an obvious yes. The need for p8e arose out of my need to add async support to my programming language, dwarf. I already had the language, and I just wanted to "bolt-on" async -- without making everything async. It turned out to be a lot of trial and error, and learning a lot more about async Rust than I wanted to know. Given that, I thought that other folks out there might benefit. So I calved off the code into a crate.

Primarily this crate is intended to be used by those that wish to have some async in their code, and don't want to commit fully. This crate does not require wrapping main in 'async fn`, and it really makes working with futures pretty simple. The features of note are:

  • an RAII executor, backed by a threadpool, that cleans up after itself when dropped
  • a task that starts paused, and are freely passed around
  • the ability to create isolated workers upon which tasks are executed
  • an ergonomic and simple API
  • parallel timers

Practically speaking, the greatest need that I had in dwarf, besides an executor, was the ability to enqueue a paused task. It's not really too difficult to explain why either. Consider this dwarf code:

async fn main() -> Future<()> {
    let future = async {
    print("The answer to life the universe and everything is: ");

As you might guess, this prints "The answer to life the universe and everything is: 42".

The interpreter is processing statements and expressions. When the block expression:

async {

is processed, we don't want the future to start executing yet, otherwise the sentence would be wrong. So we need to hold on to that future and only start it when it is awaited, after the print expression. Furthermore, we need to be able to pass that future around the interpreter as we process the next statement.


Pūteketeke is distributed under the terms of both the MIT license and the Apache License (Version 2.0).



~153K SLoC