* done

* Apply suggestions from code review

* fixup

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2021-01-21 10:31:47 -06:00 • committed by GitHub
commit dfe6797023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 33 deletions

View file

@ -1,20 +1,28 @@
discard """
output: "Exit 1\nExit 2"
targets: "c"
matrix: "--gc:refc; --gc:arc; --gc:orc"
target: "c"
"""
import coro
var coro1: CoroutineRef
when compileOption("gc", "refc") or not defined(openbsd):
# xxx openbsd failed, see tgc.nim
import coro
proc testCoroutine1() =
for i in 0..<10:
suspend(0)
var coro1: CoroutineRef
proc testCoroutine1() =
for i in 0..<10:
suspend(0)
echo "Exit 1"
proc testCoroutine2() =
coro1.wait()
echo "Exit 2"
coro1 = coro.start(testCoroutine1)
coro.start(testCoroutine2)
run()
else:
# workaround
echo "Exit 1"
proc testCoroutine2() =
coro1.wait()
echo "Exit 2"
coro1 = coro.start(testCoroutine1)
coro.start(testCoroutine2)
run()