edef1c / libfringe

a Rust library implementing safe, lightweight context switches, without relying on kernel services
https://edef1c.github.io/libfringe
Apache License 2.0
512 stars 31 forks source link

Yielder: use Cell internally to allow suspending via multiple borrows #48

Closed whitequark closed 8 years ago

whitequark commented 8 years ago

The use case is as follows: let's say I have a scheduler that uses libfringe for context switching. A single thread may open several sockets, each of which presents a std::io::Read interface, and waiting in Read::read requires having a reference to the yielder inside the socket.

This could be worked around with RefCell in the API consumer, but there is no real reason to not implement it in libfringe.