3 ms·
No, the reason this doesn't work for Rust (and even more so Swift) is that they need to call code that is not annotated. In Go the runtime knows what blocks and
by saagarjha 2y ago
No, the reason this doesn't work for Rust (and even more so Swift) is that they need to call code that is not annotated. In Go the runtime knows what blocks and what doesn't, and this lets it effectively manage its thread pool based on the state of every goroutine. If you call outside of your runtime, you lose guarantees about what that code might do: it could block indefinitely or deadlock some other code in your program. Solving this is a pretty hard problem, which is why the solutions these languages have designed are limited. (Again: Swift ships with its own runtime; there is a default "executor". It doesn't actually solve this problem for the reasons I described.)