Module coro

Procs

proc start(c: proc (); stacksize: int = defaultStackSize) {.raises: [Exception], tags: [].}
Adds coroutine to event loop. It does not run immediately.   Source
proc suspend(sleepTime: float = 0) {.raises: [], tags: [TimeEffect].}

Stops coroutine execution and resumes no sooner than after sleeptime seconds. Until then other coroutines are executed.

This is similar to a yield, or a yieldFrom:idx in Python.

  Source
proc run() {.raises: [Exception], tags: [TimeEffect, RootEffect].}
Starts main event loop which exits when all coroutines exit. Calling this proc starts execution of first coroutine.   Source
proc alive(c: proc ()): bool {.raises: [Exception], tags: [RootEffect].}
Returns true if coroutine has not returned, false otherwise.   Source
proc wait(c: proc (); interval = 0.01'f64) {.raises: [Exception],
                                      tags: [RootEffect, TimeEffect].}
Returns only after coroutine c has returned. interval is time in seconds how often.   Source