3 ms·
Async IO without the callbacks? How does that work???
by demallien 12y ago
Async IO without the callbacks? How does that work???
- jey 12y agoCoroutines. Er, I mean, "goroutines".
- kitd 12y agoYou can even do it in C (if you REALLY want) http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
- exDM69 12y agoGreen threads in Haskell do this too. You can write code in typical imperative fashion but all blocking IO statements will cause a co-operative green thread switch. Rust was also experimenting with green threads and similar async IO but they recently changed to use all-native threads.
- M2Ys4U 12y ago>Rust was also experimenting with green threads and similar async IO but they recently changed to use all-native threads. I'm pretty sure that I/O is only task-blocking in Rust, and tasks can be 1:1 or M:N with native threads.
- Jweb_Guru 12y agoThat's correct, but there's not much reason to use green threads in Rust--they don't have the advantages that green threads in Go do, besides the lack of context switching (they aren't "lightweight" because they are just as resource-intensive as threads).
- masklinn 12y ago> Rust was also experimenting with green threads and similar async IO but they recently changed to use all-native threads. tasks can be either 1:1[0] or m:n[1]. The default is 1:1, but m:n should be equally supported by force-booting with libgreen[2]. [0] http://doc.rust-lang.org/native/index.html http://doc.rust-lang.org/native/index.html [1] http://doc.rust-lang.org/green/ http://doc.rust-lang.org/green/ [2] http://doc.rust-lang.org/guide-runtime.html#force-booting-with-libgreen http://doc.rust-lang.org/guide-runtime.html#force-booting-wi...
- thu 12y agoLightweight threads in Haskell (using the excellent GHC runtime).
- coldtea 12y agoThe way async is supposed to. From coroutines to await etc.