4 ms·
A cool library that implements C coroutines, available for both idiomatic C (http://libdill.org/ http://libdill.org/) and in the same style as Go (http://libmil
by brobdingnagians 8y ago
A cool library that implements C coroutines, available for both idiomatic C (http://libdill.org/ http://libdill.org/) and in the same style as Go (http://libmill.org/ http://libmill.org/) with line by line translations
- saagarjha 8y agoFor those wondering how it works, libdill keeps track of context between function calls and does some clever stack modification in assembly.
- giovannibajo1 8y agoI wonder if it would work from Rust. I was looking at something minimal like this.
- giornogiovanna 8y agoI haven't used it at all, but doesn't Rust have experimental support for coroutines? https://github.com/rust-lang/rust/issues/43122 https://github.com/rust-lang/rust/issues/43122
- Matthias247 8y agolibdill and co implement stackful coroutines. Each coroutine has a native call stack which gets swapped out by a userspace scheduler. Rusts proposed coroutines and async functions are stackless. They are implemented as pure Compiler Transformations, and don’t allow to yield at arbitrary points. Rust actually had stackless coroutines in the past (libgreen), but moved from it due to the overhead it brought for code that didn’t require it.