Which red is your function? (gist.github.com)
from snaggen@programming.dev to rust@programming.dev on 13 Feb 2024 10:51
https://programming.dev/post/9951502

#rust

threaded - newest

syd@lemy.lol on 13 Feb 2024 11:18 next collapse

Well, this one goes to my “save but never read” box.

robinm@programming.dev on 13 Feb 2024 11:29 collapse

You shouldn’t, it’s short and interesting

syd@lemy.lol on 14 Feb 2024 09:43 collapse

Yep it was good. I also read original JS version article too 😄

robinm@programming.dev on 13 Feb 2024 11:33 next collapse

Interesting idea indeed. I’ve never used async yet, but I’m always surprised at how the problem space seems to be much more complicated than what it initially looks like.

d_k_bo@feddit.de on 13 Feb 2024 12:04 next collapse

Great post!

I ran into this problem when working with gtk-rs. For every async library that you use, you have to look carefully if it requires a specific runtime. If you want to eg. make a HTTP request with reqwest you need to make sure to spawn a task on a tokio runtime running in the background.

sugar_in_your_tea@sh.itjust.works on 13 Feb 2024 15:58 next collapse

Here’s my main takeaway with simpler language:

Rust doesn’t provide a way to abstract over async runtimes, so futures need to embed that somehow if they need access to it. So if you try to use functions intended for another runtime, you can get crashes.

This seems like it could be solved by providing an async runtime implementation in std that could be swapped out if desired (like the memory allocator).

Vorpal@programming.dev on 16 Feb 2024 16:59 collapse

The example FileDescriptorPollContext doesn’t really work. What if my runtime uses io-uring instead of polling? Those need very different interfaces to be sound. How do you abstract over that.