3 ms·
Green 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 sw
by exDM69 12y ago
Green 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...