Compile

How coroutine works

The program start from main(), then execute the argument lambda function of the source(). The lambda function start from "Start point", then call ios.run(). When echo_server accepted the connection request, open_handler is called from ios.run(). In the open_handler, sink("") is called, then the context jump to "#1". "#1" is the start point of the application logic. When source() is called, the context jump to just after the previous sink() called point, #2. Similarlly, context switches again and again between sink() and source().

We can pass the information from sink to source. The type of the information is defined as follows: