Skip to content

Commit db07edc

Browse files
committed
Expand coroutine alternatives
1 parent 8c09868 commit db07edc

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

text/0000-experimental-coroutines.md

+34-10
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,40 @@ and are likely to be coalesced around as a stable compiler feature.
451451
[alternatives]: #alternatives
452452

453453
The alternatives to list here, as this is an experimental RFC, are more targeted
454-
as alternatives to the motivation rather than the feature itself here. For
455-
example there are many alternative implementations of coroutines (or
456-
alternatives to naming!) as we've seen in previous RFCs. These alternatives,
457-
however, are more appropriate for the stabilization RFC of coroutines rather
458-
than here.
459-
460-
In terms of alternatives for an implementation of async/await, though, there
461-
don't seem to be all that many! Coroutines have critical benefits in the area of
462-
being a zero-cost abstraction which many other alternatives, such as green
463-
threads, do not have. Suggestions for alternatives though would be most welcome!
454+
as alternatives to the motivation rather than the feature itself here. Along
455+
those lines, you could imagine quite a few alternatives to the goal of tackling
456+
the 2017 roadmap goal targeted in this RFC. There's quite a bit of discussion on
457+
the [original rfc thread][rfc], but some highlight alternatives are:
458+
459+
* "Stackful coroutines" aka green threads. This strategy has, however, been
460+
thoroughly explored in historical versions of Rust. Rust long ago had green
461+
threads and libgreen, and consensus was later reached that it should be
462+
removed. There are many tradeoffs with an approach like this, but it's safe to
463+
say that we've definitely gained a lot of experimental and anecdotal evidence
464+
historically!
465+
466+
* User-mode-scheduling is another possibility along the line of green threads.
467+
Unfortunately this isn't implemented in all mainstream operating systems
468+
(Linux/Mac/Windows) and as a result isn't a viable alternative at this time.
469+
470+
* ["Resumable expressions"][cpp] is a proposal in C++ which attempts to deal
471+
with some of the "viral" concerns of async/await, but it's unclear how
472+
applicable or easy it would apply to Rust.
473+
474+
[rfc]: https://github.com/rust-lang/rfcs/pull/2033
475+
[cpp]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0114r0.pdf
476+
477+
Overall while there are a number of alternatives, the most plausible ones have a
478+
large amount of experimental and anecdotal evidence already (green
479+
threads/stackful coroutines). The next-most-viable alternative (stackless
480+
coroutines) we do not have much experience with. As a result it's believed that
481+
it's time to explore and experiment with an alternative to M:N threading with
482+
stackless coroutines, and continue to push on the 2017 roadmap goal.
483+
484+
Some more background about this motivation for exploring async/await vs
485+
alternatives can also be found [in a comment on the RFC thread][comment].
486+
487+
[comment]: https://github.com/rust-lang/rfcs/pull/2033#issuecomment-309603972
464488

465489
# Unresolved questions
466490
[unresolved]: #unresolved-questions

0 commit comments

Comments
 (0)