Skip to content

Instantly share code, notes, and snippets.

@jcouv
Last active April 23, 2018 17:29
Show Gist options
  • Save jcouv/a5d135e3c2c4960ab0a98b0d3eaf525e to your computer and use it in GitHub Desktop.
Save jcouv/a5d135e3c2c4960ab0a98b0d3eaf525e to your computer and use it in GitHub Desktop.
A manual implementation of state machine for async iterator method
Moved to https://github.com/jcouv/async-iterators/blob/master/src/Program.cs
@jcouv
Copy link
Author

jcouv commented Apr 21, 2018

Tagging @stephentoub @onovotny
So far, I've implemented using await (...) and foreach await (...) in the async-streams feature branch. I'm now looking at iterator methods (async IAsyncEnumerable<int> AsyncIterator()).

Above is a manual implementation that shows what code could be generated and some design notes to explain the flow and handshakes.
Let me know if you have any comments. Thanks

@gafter @jaredpar for feedback as well.

Note: except for the MoveNext method, which needs to be generate from user code, many methods can be refactored into a base. (see updated version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment