Async Runtimes
redixhumayun.github.io·63w·
Discuss: Hacker News
Preview
Report Post

Here’s a link to the code on a GitHub repo

I’m trying to understand async runtimes better, specifically in Rust. This post is a short attempt to build the most basic example of a future and execute it.

A better and more detailed version of this can be found in this book.

Futures

Creating a future in Rust is very straightforward. You just need to implement the Future trait, which requires one method, poll, to be implemented.

Let’s build a simple future.

use std::{
future::Future,
sync::{
mpsc::{sync_channel, Receiver, SyncSender},
Arc, Mutex,
},
task::{Context, Poll, Waker},
thread,
time::Duration,
};

use futures::{
future::{BoxFuture, Futur...

Similar Posts

Loading similar posts...