3 ms·
Could you share an example of a fiber implementation not relying a fat runtime built in the language?
by ngrilly 3y ago
Could you share an example of a fiber implementation not relying a fat runtime built in the language?
- newpavlov 3y agohttps://github.com/Xudong-Huang/may https://github.com/Xudong-Huang/may The project has some serious restrictions and unsound footguns (e.g. around TLS), but otherwise it's usable enough. There are also a number of C/C++ libraries, but I can not comment on those.
- ngrilly 3y agoNeat. Thanks for sharing! Interestingly, may-minihttp is faring very well in the TechEmpower benchmark [1], for whatever those benchmarks are worth. The code is also surprisingly straightforward [2]. [1] https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/ [2] https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Rust/may-minihttp/src/main.rs https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...
- anonymoushn 3y agoFor example https://github.com/creationix/libco https://github.com/creationix/libco The required thing is mostly just to dump your registers on the stack and jump.
- noselasd 3y agoI do think implementations like that are not particularly useful though. You want a runtime to handle and multiplex blocking calls - otherwise if you perform any blocking calls (mostly I/O) in one fiber, you block everything - so what use are those fibers ?
- anonymoushn 3y agoThe answer is the same as in async Rust, right? "Don't do that." If you wanted to use this for managing a bunch of I/O contexts per OS thread then you would need to bring an event loop and a bunch of functions that hook up your event loop to whatever asynchronous I/O facilities your OS provides. Sort of like in async Rust.