scala/async — pull request #96 by retronym (2014-12-15 02:53:10+00:00)
Title: Avoid unbounded stack consumption for synchronous control flow

Previously, as sequence of state transitions that did not pass through an
asynchrous boundary incurred stack frames. The trivial loop in the enclosed
test case would then overflow the stack.

This commit merges the `resume` and `apply(tr: Try[Any])` methods into a
`apply`. It changes the body of this method to be an infinite loop with
returns at the terminal points in the state machine (or at a terminal
failure.)

To allow merging of these previously separate matches, states that contain
an await are now allocated two state ids: one for the setup code that calls
`onComplete`, and one for the code in the continuation that records the
result and advances the state machine.

Review by @phaller / @danarmak