Async Runtimes
redixhumayun.github.io·68w·
Discuss: Hacker News

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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help