Expand description
Single thread executor library for building async runtimes.
Note: as for now it is more a research project rather then production ready library.
The async/await machinery in Rust compiler in a nutshell provides a transformation of a synchronous looking code into the struct that impls std::future::Future and then user need a library to run such future (or “poll the future to completion”). Popular async runtime libraries are tokio, async-std, smol.
The library that runs the future (usually with something called block_on() function) can have two distinct parts in its API:
-
executor - something that organizes the futures from user into a set of tasks for execution (like spawn(), JoinHandle)
-
reactor - schedule I/O using OS API (epoll, io_uring, completion port) and be able awake a task when certain I/O event occurs.
This library implements the executor part of the async runtime. Suppose I would like to create async runtime named Mega. I can do it using the aiur crate:
- Create a crate mega_runtime that depends aiur
- Implement aiur::Reactor in MegaReactor and API to schedule I/O
- Now I can have a
type MegaRuntime = aiur::Runtime<MegaReactor>
, which is now a complete runtime with both executor and reactor. - Apps are using MegaRuntime not knowing anything that there is some aiur used under the hood.
As aiur does not have anything OS-specific, it can be used on any OS with std. For testing purposes it has toy reactor that only supports async sleeping.
Major distinction from popular libraries that aiur only provides a single thread executor. It seems to be a lager topic and can be discussed later.
There other ideas where ongoing research happens:
- structured concurrency
- async destruction
- nostd