Amanieu / corosensei

A fast and safe implementation of stackful coroutines in Rust
Apache License 2.0
191 stars 17 forks source link

Stackfull or stackless? Also comparison vs. Rust RFC2033 #11

Closed cameronelliott closed 2 years ago

cameronelliott commented 2 years ago

This looks amazing! Thank you for developing it.

I'm learning about a coroutines and generators under Rust, and that's how I discovered this. (I'd like to use them for protocol implementation)

I wonder if you could share a bit about Corosensi vs the unstable generators feature in Rust. Like, it is stackfull, or stackless: link

The features are covered well in the readme, but I just wonder if you would consider writing a bit more about the implementation, and and comparisons to the unstable generators.

Thank you

cameronelliott commented 2 years ago

One more thought, the Stackoverflow article linked above says:

Without stackfulness and first-class semantics, some useful execution control flows cannot be supported (for instance cooperative multitasking or checkpointing).

So, maybe Corosensi is both stackful, and provides first-class continuations?, which means effectively full cooperative multitasking and checkpointing are possible?? I'm not really sure.

Thanks.

cameronelliott commented 2 years ago

Goodness, sorry. I've been reading a bit more. I guess stackful coroutines are the same as Goroutines, or green threads. I was confused, and thought all coroutines were kept on the same stack. Apparently not.

Amanieu commented 2 years ago

Yes this crate only provides stackful coroutines. You can build a cooperative scheduler on top of it, but this crate only provide the low-level (but safe) task switching functionality.