4 ms·
> Can you give one that reaches this goal? First-class continuations. They are an efficient building block for everything from calling asynchronous I/O routine
by sedachv 7y ago
> Can you give one that reaches this goal?
First-class continuations. They are an efficient building block for everything from calling asynchronous I/O routines without turning your code into callback spaghetti, to implementing coroutines and green threads. Goroutines are a special and poorly implemented case of continuations. Gambit-C has had preemptive green threads with priorities and mailboxes at less than 1KiB per thread memory overhead for over a decade now, all built on top of first-class continuations.
http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf
- Rusky 7y agoFirst-class continuations are too unrestricted to match the performance of Rust-style async/await. If you take on a few limitations you can get there, but then those are exactly the things people complain about.
- sedachv 7y agoIt is worse than that. First-class continuations add a small overhead for stack operations, and they always have more memory overhead than callbacks/async transformation into callbacks. But the comment I was replying was about Go, not Rust. For the small overhead that first-class continuations have, they provide a simple and efficient way to handle coroutines, generators, asynchronous I/O, and green threads.