←back to thread

100 points 0x1997 | 2 comments | | HN request time: 0.51s | source
Show context
efskap ◴[] No.45789798[source]
Using stuff like this, does it make sense to use Rust in a golang-style where instead of async and its function colouring, you spawn coroutines and synchronize over channels?
replies(2): >>45789835 #>>45791783 #
thrance ◴[] No.45789835[source]
It doesn't matter if you use channels or mutexes to communicate between tasks, you still need your function to be async to spawn it as a coroutine. Your only choice is between coroutines (async tasks spawned on an executor) or regular OS threads. Channels work with both, the rule of thumb is to use async when your workload is IO-bound, and threads when it is compute-bound. Then, it's up to you whether you communicate by sharing memory or share memory by communicating.
replies(2): >>45790697 #>>45791456 #
1. nicoburns ◴[] No.45791456[source]
> Your only choice is between coroutines (async tasks spawned on an executor) or regular OS threads.

Thats not true. There are stackgul coroutine libraries in Rust too. I believe there's one called "may". They are admittedly not that widely used, but they are available.

replies(1): >>45791939 #
2. steveklabnik ◴[] No.45791939[source]
May has unresolvable soundness issues, which is part of why it’s not popular.