… | |
… | |
109 | event handlers), then it must be prepared to be called recursively |
109 | event handlers), then it must be prepared to be called recursively |
110 | itself. |
110 | itself. |
111 | |
111 | |
112 | SIMPLE COROUTINE CREATION |
112 | SIMPLE COROUTINE CREATION |
113 | async { ... } [@args...] |
113 | async { ... } [@args...] |
114 | Create a new coroutine and return it's coroutine object (usually |
114 | Create a new coroutine and return its coroutine object (usually |
115 | unused). The coroutine will be put into the ready queue, so it will |
115 | unused). The coroutine will be put into the ready queue, so it will |
116 | start running automatically on the next scheduler run. |
116 | start running automatically on the next scheduler run. |
117 | |
117 | |
118 | The first argument is a codeblock/closure that should be executed in |
118 | The first argument is a codeblock/closure that should be executed in |
119 | the coroutine. When it returns argument returns the coroutine is |
119 | the coroutine. When it returns argument returns the coroutine is |
… | |
… | |
444 | |
444 | |
445 | Coro offers two functions specifically designed to make this easy, |
445 | Coro offers two functions specifically designed to make this easy, |
446 | "Coro::rouse_cb" and "Coro::rouse_wait". |
446 | "Coro::rouse_cb" and "Coro::rouse_wait". |
447 | |
447 | |
448 | The first function, "rouse_cb", generates and returns a callback that, |
448 | The first function, "rouse_cb", generates and returns a callback that, |
449 | when invoked, will save it's arguments and notify the coroutine that |
449 | when invoked, will save its arguments and notify the coroutine that |
450 | created the callback. |
450 | created the callback. |
451 | |
451 | |
452 | The second function, "rouse_wait", waits for the callback to be called |
452 | The second function, "rouse_wait", waits for the callback to be called |
453 | (by calling "schedule" to go to sleep) and returns the arguments |
453 | (by calling "schedule" to go to sleep) and returns the arguments |
454 | originally passed to the callback. |
454 | originally passed to the callback. |