async_runtime Part II: Components of an asynchronous runtime
In the previous post we saw how asynchronous programming can be used to write concurrent programs in Rust. In this post, we will start writing our own asynchronous runtime, and we will see an overview of its different components. Our implementation is heavily inspired by this series of posts and the actual code of the smol runtime. Components The two main components of an asynchronous runtime are the Executor and the Reactor. The Executor is responsible for scheduling tasks and executing them. It contains the main execution loop of the runtime, which is responsible for polling the available tasks. The Reactor is responsible for registering resources that tasks are waiting for, and for waking the appropriate tasks when those resources are available. The Executor Here is the main loop of our Executor. Note that we are purposefully writing a single-threaded runtime, so we allow our Executor to be !Send and !Sync. ...