Develop an async runtime like thing in Rust for educational purpose.

Overview

How-not-to-async-rs

Develop an async runtime like thing in Rust for educational purpose.

What this is not

  • This is not going to be a blog post explaining how things are working. Just dive into the code and hope comments are enough :)
  • There are many bugs and incorrect design decisions. Some happened accidently and some are created knowingly. Not a lot of effort and time was given for this. A lot of code is taken and modified from the futures crate (incl futures-task, futures-executor etc).
  • Have not implemented block-on. But it is easy enough if you got as far as understanding this example.

Prerequisite

  • Need to have a basic undestanding of Pinning, Future, Waker etc.
  • This excercise just aims at combining all these concepts together to give a general idea on how an async runtime can be implemented.

For understanding about these concepts, I highly recommend Jon Gjengset youtube videos:

How to approach

The source files have concepts implemented in a self contained manner.

  1. future.rs - To know about Futures and other helper data structures and traits.
  2. task.rs - For understanding RawWakers, Wakers, AtomicWakers and ArcWake.
  3. spawn.rs + thread_pool.rs - Scheduler implementation

This completes basic scheduler. The next part is for understanding how to link a IoSource reactor pattern to drive a future.

  1. net/io_service.rs - Combines an event loop and scheduler together.
  2. net/socket.rs - Example only for accepting a socket connection.
  3. main.rs - Has examples.
You might also like...
The feature-rich, portable async channel library

The feature-rich, portable async channel library crates.io docs.rs Why use Postage? Includes a rich set of channels. | barrier | broadcast | dispa

Mix async code with CPU-heavy thread pools using Tokio + Rayon

tokio-rayon Mix async code with CPU-heavy thread pools using Tokio + Rayon Resources Documentation crates.io TL;DR Sometimes, you're doing async stuff

Another Async IO Framework based on io_uring

kbio, the Async IO Framework based on io_uring, is used in KuiBaDB to implement async io. Features Support multi-threading concurrent task submission.

async-alloc-counter measures max allocations in a future invocation

async-alloc-counter measures max allocations in a future invocation see examples/ for usage This allocator can be used as follows: use async_alloc_cou

Async `TryFrom/TryInto` traits

async-convert Async TryFrom/TryInto traits API Docs | Releases | Contributing Installation $ cargo add async-convert Safety This crate uses #![deny(un

Simple async codec for rkyv. Reuses streaming buffer for maximum speed

rkyv_codec Simple async codec for rkyv. Reuses streaming buffer for maximum speed! This crate provides a makeshift adaptor for streaming &ArchivedObj

You can name anonymous Future from async fn without dyn or Box!

rename-future You can name anonymous Future from async fn without dyn or Box! PLEASE READ THIS THIS PROJECT NOT YET WELL TESTED! DON'T USE THIS IN PRO

The most fundamental type for async synchronization: an intrusive linked list of futures

wait-list This crate provides WaitList, the most fundamental type for async synchronization. WaitList is implemented as an intrusive linked list of fu

Ector is an open source async, no-alloc actor framework for embedded devices

Ector is an open source async, no-alloc actor framework for embedded devices. Ector is an open source async, no-alloc actor framework for embedded dev

Owner
Arun Muralidharan
Arun Muralidharan
A Rust framework to develop and use plugins within your project, without worrying about the low-level details.

VPlugin: A plugin framework for Rust. Website | Issues | Documentation VPlugin is a Rust framework to develop and use plugins on applications and libr

VPlugin 11 Dec 31, 2022
A artifact repo written in rust ! (still in develop)

Rstore A Rust-based artifact repository (still in development) usage name http frame axum orm disel s3 aws-sdk-s3 log log4rs config config-rs http cli

Rambler 3 May 8, 2023
[DEPRECATED] password manager thing

NOTE: this is pretty much abandoned, I recommend Bitwarden now. There is an export command in the CLI that produces CSV suitable for import into Bitwa

null 312 Oct 22, 2022
Graceful shutdown util for Rust projects using the Tokio Async runtime.

Shutdown management for graceful shutdown of tokio applications. Guard creating and usage is lock-free and the crate only locks when: the shutdown sig

Plabayo 54 Sep 29, 2023
Golang like WaitGroup implementation for sync/async Rust.

wg Golang like WaitGroup implementation for sync/async Rust.

Al Liu 8 Dec 6, 2022
single file, std only, async Rust executor

whorl - A single file, std only, async Rust executor whorl was created to teach you how async executors work in Rust. It is not the fastest executor n

Michael Gattozzi 459 Dec 29, 2022
BPF library for Async Rust, complementary for libbpf-rs.

libbpf-async A library for writing BPF programs in Async Rust, complementary for libbpf-rs, Rust wrapper for libbpf. Currently, this provides Async-fr

FUJITA Tomonori 13 Nov 9, 2022
Rust library for one-time async initialization

async-lazy An async version of once_cell::sync::Lazy, std::sync::OnceLock or lazy_static. Uses tokio's sychronization primitives. This crate offers an

Jules Bertholet 5 Jun 9, 2023
Async Rust cron scheduler running on Tokio.

Grizzly Cron Scheduler A simple and easy to use scheduler, built on top of Tokio, that allows you to schedule async tasks using cron expressions (with

Ivan Brko 4 Feb 27, 2024
Async executor for WebAssembly

There are a number of async task executors available in Rust's ecosystem. However, most (if not all?) of them rely on primitives that might not be available or optimal for WebAssembly deployment at the time.

wasm.rs 65 Dec 31, 2022